Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: CORS origin 변경 #128

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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