fix(parapharmacy-api): use CORS_ORIGIN env var for Swagger server URL
Run Tests on Branches / Detect Changes (push) Successful in 13s
Run Tests on Branches / Backend Tests (push) Has been skipped
Run Tests on Branches / Frontend Tests (push) Has been skipped
Run Tests on Branches / Frontend Mobile Tests (push) Has been skipped
Run Tests on Branches / PIP Platform Tests (push) Has been skipped
Run Tests on Branches / Parapharmacy API Tests (push) Failing after 7s

Swagger UI hardcoded localhost:3002, causing NetworkError when accessed
from the deployed server. Now reads CORS_ORIGIN to build the correct
server URL for API calls from the Swagger UI.
This commit is contained in:
Antoni Nuñez Romeu
2026-07-16 23:14:48 +02:00
parent dfd84da84a
commit 9eb174dc8b
3 changed files with 8 additions and 3 deletions
+6 -2
View File
@@ -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: {