@@ -16,11 +16,29 @@ const booking_proxy_1 = __importDefault(require("./routes/booking.proxy"));
1616const app = ( 0 , express_1 . default ) ( ) ;
1717const port = process . env . GATEWAY_PORT || 4000 ;
1818app . 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+ ] ;
1932app . 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} ) ) ;
2543console . log ( "AUTH_SERVICE_URL =" , process . env . AUTH_SERVICE_URL ) ;
2644app . use ( express_1 . default . json ( ) ) ;
0 commit comments