fix: configure CORS to allow frontend and PWA domains
- Update backend main.ts to include www.placebo.mk in allowed origins - Add logging to show which origins are allowed - Set FRONTEND_URL, PWA_URL, STRAPI_URL env vars in docker-compose - This fixes 'No Access-Control-Allow-Origin header' CORS errors
This commit is contained in:
1 parent
c3b01de12e
commit
d573846e5c
2 files changed
+8
-3
No files matched your search
+5
-1
@@ -6,11 +6,15 @@ import { JwtAuthPublicGuard } from './modules/auth/jwt-auth-public.guard';
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
// Build allowed origins list from environment variables
|
||||
const allowedOrigins = [
|
||||
process.env.FRONTEND_URL ?? 'http://localhost:5173',
|
||||
'https://www.placebo.mk', // Also allow www subdomain
|
||||
process.env.PWA_URL ?? 'http://localhost:5174',
|
||||
process.env.STRAPI_URL ?? 'http://localhost:1337',
|
||||
];
|
||||
].filter(Boolean); // Remove any undefined/null values
|
||||
|
||||
console.log('CORS enabled for origins:', allowedOrigins);
|
||||
|
||||
app.enableCors({
|
||||
origin: allowedOrigins,
|
||||
|
||||
Reference in new issue
Block a user