File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,11 +36,27 @@ app.use(helmet());
3636
3737// CORS Configuration for Production
3838const corsOptions = {
39- origin : [
40- 'http://localhost:5173' , // Local development
41- 'https://ai-grant-crawler-a2a-pro.vercel.app' , // Production frontend
42- 'https://ai-grant-crawler-a2a-pro-*.vercel.app' // Vercel preview deployments
43- ] ,
39+ origin : function ( origin , callback ) {
40+ const allowedOrigins = [
41+ 'http://localhost:5173' ,
42+ 'https://ai-grant-crawler-a2a-pro.vercel.app'
43+ ] ;
44+
45+ // Allow requests with no origin (like mobile apps or curl requests)
46+ if ( ! origin ) return callback ( null , true ) ;
47+
48+ // Check if origin is in allowed list
49+ if ( allowedOrigins . includes ( origin ) ) {
50+ return callback ( null , true ) ;
51+ }
52+
53+ // Allow all Vercel preview deployments
54+ if ( origin . match ( / ^ h t t p s : \/ \/ a i - g r a n t - c r a w l e r - a 2 a - p r o - .* \. v e r c e l \. a p p $ / ) ) {
55+ return callback ( null , true ) ;
56+ }
57+
58+ callback ( new Error ( 'Not allowed by CORS' ) ) ;
59+ } ,
4460 credentials : true ,
4561 optionsSuccessStatus : 200
4662} ;
You can’t perform that action at this time.
0 commit comments