File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,10 +37,10 @@ app.use(helmet());
3737const parseCorsOrigins = ( ) => {
3838 const origins = new Set ( ) ;
3939
40- if ( process . env . FRONTEND_URL ) origins . add ( process . env . FRONTEND_URL ) ;
40+ if ( process . env . FRONTEND_URL ) origins . add ( String ( process . env . FRONTEND_URL ) . trim ( ) . toLowerCase ( ) ) ;
4141 if ( process . env . CORS_ORIGINS ) {
4242 for ( const origin of process . env . CORS_ORIGINS . split ( ',' ) . map ( ( o ) => o . trim ( ) ) . filter ( Boolean ) ) {
43- origins . add ( origin ) ;
43+ origins . add ( origin . toLowerCase ( ) ) ;
4444 }
4545 }
4646
@@ -54,8 +54,9 @@ app.use(
5454 cors ( {
5555 origin : ( origin , cb ) => {
5656 if ( ! origin ) return cb ( null , true ) ;
57- if ( allowedOrigins . has ( origin ) ) return cb ( null , true ) ;
58- if ( origin . startsWith ( 'chrome-extension://' ) ) return cb ( null , true ) ;
57+ const normalizedOrigin = origin . toLowerCase ( ) ;
58+ if ( allowedOrigins . has ( normalizedOrigin ) ) return cb ( null , true ) ;
59+ if ( normalizedOrigin . startsWith ( 'chrome-extension://' ) ) return cb ( null , true ) ;
5960 return cb ( new Error ( 'Not allowed by CORS' ) ) ;
6061 } ,
6162 credentials : true ,
You can’t perform that action at this time.
0 commit comments