File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4545{
4646 options . AddDefaultPolicy ( policy =>
4747 {
48- policy . WithOrigins ( builder . Configuration . GetSection ( "Cors:AllowedOrigins" ) . Get < string [ ] > ( ) ?? new [ ] { "http://localhost:3000" } )
48+ var allowedOrigins = builder . Configuration . GetSection ( "Cors:AllowedOrigins" ) . Get < string [ ] > ( )
49+ ?? new [ ] { "http://localhost:3000" } ;
50+
51+ policy . WithOrigins ( allowedOrigins )
4952 . AllowAnyHeader ( )
5053 . AllowAnyMethod ( )
5154 . AllowCredentials ( ) ;
6366 options . LoginPath = "/api/auth/login" ;
6467 options . LogoutPath = "/api/auth/logout" ;
6568 options . Cookie . Name = "JobHelper.Auth" ;
66- options . Cookie . HttpOnly = true ;
67- options . Cookie . SecurePolicy = CookieSecurePolicy . Always ; // Require HTTPS (backend is on HTTPS)
69+ options . Cookie . HttpOnly = false ;
70+ options . Cookie . SecurePolicy = CookieSecurePolicy . SameAsRequest ; // Require HTTPS (backend is on HTTPS)
6871 options . Cookie . SameSite = SameSiteMode . None ; // Allow cross-site for different domains
6972 options . Cookie . IsEssential = true ; // Mark as essential for GDPR compliance
7073 options . ExpireTimeSpan = TimeSpan . FromHours ( 24 ) ;
166169// Add Scalar API documentation UI (modern alternative to Swagger UI)
167170app . MapScalarApiReference ( ) ;
168171
172+ // IMPORTANT: CORS must be called before Authentication and Authorization
169173app . UseCors ( ) ;
170174app . UseAuthentication ( ) ;
171175app . UseAuthorization ( ) ;
You can’t perform that action at this time.
0 commit comments