Skip to content

Commit

Permalink
chore: nginx cors설정 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Ogu1208 committed Oct 20, 2024
1 parent 5fcf4c6 commit c08189f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 6 additions & 4 deletions nginx/conf.d/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ server {
proxy_set_header Authorization $http_authorization;
proxy_pass_header Authorization;

# CORS headers for all requests
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;

if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type';
add_header 'Access-Control-Allow-Credentials' 'true';
return 204;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/sch/chekirout/common/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ public void addCorsMappings(CorsRegistry registry) {
.allowedOrigins("http://localhost:3000", "https://chekirout-fe.vercel.app")
.allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS")
.allowedHeaders("Authorization", "Content-Type")
.exposedHeaders("Authorization")
.exposedHeaders("Custom-Header")
.exposedHeaders("Authorization", "Custom-Header")
.allowCredentials(true)
.maxAge(3600);
}
Expand Down

0 comments on commit c08189f

Please sign in to comment.