Skip to content

Commit bd854bd

Browse files
authored
allow access of api for new ui
1 parent 8757ad5 commit bd854bd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

server/main.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ async function main() {
2929

3030
// allow origin https://localhost
3131
app.use((_req, res, next) => {
32-
res.header('Access-Control-Allow-Origin', 'https://localhost');
32+
const allowedOrigins = [
33+
'https://preview--acode-code-hub.lovable.app', // temp, for dev only
34+
'http://localhost:8080', // temp, for dev only
35+
'https://localhost',
36+
];
37+
const origin = req.headers.origin;
38+
39+
if (allowedOrigins.includes(origin)) {
40+
res.header('Access-Control-Allow-Origin', origin);
41+
}
3342
// allow content-type
3443
res.header('Access-Control-Allow-Headers', 'Content-Type');
3544
next();

0 commit comments

Comments
 (0)