fix(parapharmacy-api): use CORS_ORIGIN env var for Swagger server URL #40
@@ -18,6 +18,7 @@ N8N_EMAIL=admin@farmafinder.com
|
||||
|
||||
# Parapharmacy API
|
||||
PARAPHARMACY_API_URL=http://parapharmacy-api:3002
|
||||
PARAPHARMACY_CORS_ORIGIN=http://localhost:4000
|
||||
MONGODB_URI=mongodb://mongodb:27017/parapharmacy
|
||||
|
||||
# Expo Push Notifications (mobile)
|
||||
|
||||
@@ -12,6 +12,10 @@ import scraperRouter from './routes/scraper.js';
|
||||
const app = express();
|
||||
|
||||
// Swagger configuration
|
||||
const swaggerServerUrl = process.env.CORS_ORIGIN
|
||||
? process.env.CORS_ORIGIN.replace(/\/$/, '') // strip trailing slash
|
||||
: `http://localhost:${config.port}`;
|
||||
|
||||
const swaggerOptions = {
|
||||
definition: {
|
||||
openapi: '3.0.0',
|
||||
@@ -22,8 +26,8 @@ const swaggerOptions = {
|
||||
},
|
||||
servers: [
|
||||
{
|
||||
url: `http://localhost:${config.port}`,
|
||||
description: 'Development server',
|
||||
url: swaggerServerUrl,
|
||||
description: process.env.CORS_ORIGIN ? 'Production server' : 'Development server',
|
||||
},
|
||||
],
|
||||
components: {
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ services:
|
||||
PORT: "3002"
|
||||
NODE_ENV: production
|
||||
MONGODB_URI: mongodb://mongodb:27017/parapharmacy
|
||||
CORS_ORIGIN: http://localhost:4000
|
||||
CORS_ORIGIN: ${PARAPHARMACY_CORS_ORIGIN:-http://localhost:4000}
|
||||
depends_on:
|
||||
- mongodb
|
||||
|
||||
|
||||
Reference in New Issue
Block a user