Skip to content

Commit 4fb75cb

Browse files
committed
feat(cd): add frontend cd twenty
1 parent c0f246c commit 4fb75cb

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

  • nodejs-autospace/api-gateway/src

nodejs-autospace/api-gateway/src/index.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,33 @@ const app = express();
1515
const port = process.env.GATEWAY_PORT || 4000;
1616

1717
app.use(helmet());
18+
19+
// app.use(
20+
// cors({
21+
// origin: process.env.FRONTEND_URL!,
22+
// credentials: true,
23+
// methods: ["GET", "POST", "PUT", "DELETE", "PATCH"],
24+
// allowedHeaders: ["Content-Type", "Authorization", "x-user-id", "x-role"],
25+
// }),
26+
// );
27+
28+
// in local commend that
29+
30+
const allowedOrigins = [
31+
"https://autospace.space",
32+
"https://www.autospace.space",
33+
];
34+
1835
app.use(
1936
cors({
20-
origin: process.env.FRONTEND_URL!,
37+
origin: (origin, callback) => {
38+
if (!origin || allowedOrigins.includes(origin)) {
39+
callback(null, true);
40+
} else {
41+
callback(new Error("Not allowed by CORS"));
42+
}
43+
},
2144
credentials: true,
22-
methods: ["GET", "POST", "PUT", "DELETE", "PATCH"],
23-
allowedHeaders: ["Content-Type", "Authorization", "x-user-id", "x-role"],
2445
}),
2546
);
2647

0 commit comments

Comments
 (0)