fix: enhance CORS configuration for production with Nginx proxy

- Add enhanced CORS headers for Swagger UI compatibility
- Add OPTIONS method support for preflight requests
- Add additional middleware for CORS preflight handling
- Add debug endpoint /api/cors-test for CORS troubleshooting
- Improve Swagger UI configuration for production deployment
This commit is contained in:
Michilis
2025-07-15 21:56:55 +00:00
parent 91259e98c6
commit bf1f368a24
2 changed files with 37 additions and 4 deletions

View File

@@ -6,6 +6,11 @@ const apiDomain = process.env.API_DOMAIN || 'localhost:3000';
const isProduction = process.env.NODE_ENV === 'production';
const protocol = isProduction ? 'https' : 'http';
// For production behind Nginx, we need to ensure the URL doesn't include the internal port
const serverUrl = isProduction
? `${protocol}://${apiDomain}`
: `${protocol}://${apiDomain}`;
const options = {
definition: {
openapi: '3.0.0',
@@ -24,7 +29,7 @@ const options = {
},
servers: [
{
url: `${protocol}://${apiDomain}`,
url: serverUrl,
description: isProduction ? 'Production server' : 'Development server'
}
],