From 85772a26fa8a498004f2c635e4121f0e085eb8a4 Mon Sep 17 00:00:00 2001 From: MinhhTien <92145479+MinhhTien@users.noreply.github.com> Date: Sun, 26 May 2024 08:34:08 +0700 Subject: [PATCH] chore: enable cors --- example.env | 2 +- src/main.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/example.env b/example.env index db79eb5..7fbc809 100644 --- a/example.env +++ b/example.env @@ -22,7 +22,7 @@ GOOGLE_CLIENT_ID= GOOGLE_CLIENT_SECRET= #FURNIQUE -CORS_VALID_ORIGINS=localhost,ngrok-free +CORS_VALID_ORIGINS=localhost,ngrok-free,furnique.tech WEB_URL=https://www.furnique.tech SERVER_URL=https://api.furnique.tech diff --git a/src/main.ts b/src/main.ts index 0fb1527..7d6bb3c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -20,7 +20,7 @@ async function bootstrap() { const app = await NestFactory.create(AppModule) // Sentry - if (process.env.NODE_ENV === 'development') { //'production' + if (process.env.NODE_ENV === 'production') { sentryInit({ dsn: process.env.SENTRY_DSN, integrations: [ @@ -35,9 +35,9 @@ async function bootstrap() { // Set sampling rate for profiling - this is relative to tracesSampleRate profilesSampleRate: 1.0 }) + app.use(SentryHandlers.requestHandler()) + app.use(SentryHandlers.tracingHandler()) } - app.use(SentryHandlers.requestHandler()) - app.use(SentryHandlers.tracingHandler()) const logger = app.get(AppLogger) const discordService = app.get(DiscordService) @@ -81,10 +81,10 @@ async function bootstrap() { // Example: process.env.CORS_VALID_ORIGINS=localhost,ngrok-free => parse to [ /localhost/, /ngrok-free/ ] const origins = process.env.CORS_VALID_ORIGINS?.split(',').map((origin) => new RegExp(origin)) || [ /localhost/, - /ngrok-free/ + /ngrok-free/, + /furnique.tech/ ] - // app.enableCors({ origin: origins }); // use later - app.enableCors() + app.enableCors({ origin: origins }); const port = process.env.PORT || 5000 await app.listen(port)