Skip to content

Commit 9115708

Browse files
committed
feat(cd): add frontend cd twentione
1 parent 4fb75cb commit 9115708

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

  • nodejs-autospace/api-gateway/dist

nodejs-autospace/api-gateway/dist/index.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,29 @@ const booking_proxy_1 = __importDefault(require("./routes/booking.proxy"));
1616
const app = (0, express_1.default)();
1717
const port = process.env.GATEWAY_PORT || 4000;
1818
app.use((0, helmet_1.default)());
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+
// in local commend that
28+
const allowedOrigins = [
29+
"https://autospace.space",
30+
"https://www.autospace.space",
31+
];
1932
app.use((0, cors_1.default)({
20-
origin: process.env.FRONTEND_URL,
33+
origin: (origin, callback) => {
34+
if (!origin || allowedOrigins.includes(origin)) {
35+
callback(null, true);
36+
}
37+
else {
38+
callback(new Error("Not allowed by CORS"));
39+
}
40+
},
2141
credentials: true,
22-
methods: ["GET", "POST", "PUT", "DELETE", "PATCH"],
23-
allowedHeaders: ["Content-Type", "Authorization", "x-user-id", "x-role"],
2442
}));
2543
console.log("AUTH_SERVICE_URL =", process.env.AUTH_SERVICE_URL);
2644
app.use(express_1.default.json());

0 commit comments

Comments
 (0)