Skip to content

Commit 7843f82

Browse files
authored
Fix/sofia cors hardcode (#1058)
* Use Sofia.url for CORS configuration * hardcode CORS
1 parent f68ddf8 commit 7843f82

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

server/index.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,24 @@ module.exports = function (app) {
1717
require
1818
);
1919

20-
// Use `sofiaUrl` only from env or Ember config (no hardcoded fallbacks).
21-
// Load Ember config function with the current environment if provided.
22-
const config = require('../config/environment')(
23-
process.env.EMBER_ENV || process.env.NODE_ENV
24-
);
25-
const sofiaUrl = process.env.SOFIA_URL || config.sofiaUrl;
20+
// Hardcoded allowed origins for CORS
21+
const allowedOrigins = new Set([
22+
'http://localhost:5000',
23+
'https://stagingstreep.csvalpha.nl',
24+
'https://streep.csvalpha.nl',
25+
]);
2626

27-
app.use(cors({ origin: sofiaUrl }));
27+
app.use(
28+
cors({
29+
origin: function (origin, callback) {
30+
// Allow requests with no origin (like mobile apps or curl)
31+
if (!origin) return callback(null, true);
32+
if (allowedOrigins.has(origin)) return callback(null, true);
33+
return callback(new Error('Not allowed by CORS'));
34+
},
35+
credentials: true,
36+
})
37+
);
2838

2939
// Log proxy requests
3040
const morgan = require('morgan');

0 commit comments

Comments
 (0)