Skip to content

Commit

Permalink
refactor: CORS origin 변경 (#128)
Browse files Browse the repository at this point in the history
* refactor: CORS origin 변경
  • Loading branch information
iamjooon2 authored Aug 3, 2023
1 parent 07c5159 commit 7ab0564
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions backend/src/main/java/zipgo/common/config/WebConfig.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package zipgo.common.config;

import static org.springframework.http.HttpHeaders.LOCATION;

import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
Expand All @@ -13,12 +10,19 @@
import zipgo.auth.presentation.JwtArgumentResolver;
import zipgo.auth.util.JwtProvider;

import java.util.List;

import static org.springframework.http.HttpHeaders.LOCATION;

@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {

private static final String ALLOW_ALL_PATH = "/**";
private static final String ALLOWED_METHODS = "*";
private static final String MAIN_SERVER_DOMAIN = "https://zipgo.pet";
private static final String MAIN_SERVER_WWW_DOMAIN = "https://www.zipgo.pet";
private static final String FRONTEND_LOCALHOST = "http://localhost:3000";

private final AuthInterceptor authInterceptor;
private final JwtProvider jwtProvider;
Expand All @@ -27,7 +31,7 @@ public class WebConfig implements WebMvcConfigurer {
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping(ALLOW_ALL_PATH)
.allowedMethods(ALLOWED_METHODS)
.allowedOrigins("http://localhost:3000", "http://localhost", "http://3.39.240.11")
.allowedOrigins(MAIN_SERVER_DOMAIN, MAIN_SERVER_WWW_DOMAIN, FRONTEND_LOCALHOST)
.exposedHeaders(LOCATION);
}

Expand Down

0 comments on commit 7ab0564

Please sign in to comment.