@@ -20,16 +20,37 @@ interface AppDeps {
2020export function createApp ( deps : AppDeps ) {
2121 const app = express ( ) ;
2222
23- app . use (
24- cors ( {
25- origin : deps . corsOrigin ?? '*' ,
26- credentials : true ,
27- methods : [ 'GET' , 'POST' , 'PUT' , 'DELETE' , 'PATCH' , 'OPTIONS' ] ,
28- allowedHeaders : [ 'Content-Type' , 'Authorization' , 'Cookie' ] ,
29- exposedHeaders : [ 'Set-Cookie' ] ,
30- maxAge : 86400 , // 24 hours
31- } ) ,
32- ) ;
23+ // Log all incoming requests for debugging
24+ app . use ( ( req , res , next ) => {
25+ console . log ( `[${ new Date ( ) . toISOString ( ) } ] ${ req . method } ${ req . path } ` ) ;
26+ console . log ( 'Origin:' , req . headers . origin ) ;
27+ console . log ( 'Headers:' , JSON . stringify ( req . headers , null , 2 ) ) ;
28+ next ( ) ;
29+ } ) ;
30+
31+ const corsOptions = {
32+ origin : deps . corsOrigin ?? '*' ,
33+ credentials : true ,
34+ methods : [ 'GET' , 'POST' , 'PUT' , 'DELETE' , 'PATCH' , 'OPTIONS' ] ,
35+ allowedHeaders : [ 'Content-Type' , 'Authorization' , 'Cookie' ] ,
36+ exposedHeaders : [ 'Set-Cookie' ] ,
37+ maxAge : 86400 , // 24 hours
38+ } ;
39+
40+ console . log ( 'CORS configuration:' , {
41+ origin : corsOptions . origin ,
42+ credentials : corsOptions . credentials ,
43+ methods : corsOptions . methods ,
44+ } ) ;
45+
46+ app . use ( cors ( corsOptions ) ) ;
47+
48+ // Log after CORS middleware
49+ app . use ( ( req , res , next ) => {
50+ console . log ( 'After CORS - Response headers:' , res . getHeaders ( ) ) ;
51+ next ( ) ;
52+ } ) ;
53+
3354 app . use ( express . json ( { limit : '10mb' } ) ) ;
3455 app . use ( cookieParser ( ) ) ;
3556 const authMiddleware = createAuthMiddleware ( {
0 commit comments