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

Allow Oriign 수정 #53

Merged
merged 5 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions src/main/java/com/example/parking/config/WebMvcConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.swagger.v3.oas.models.PathItem;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
Expand All @@ -19,6 +20,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
private final AuthInterceptor authInterceptor;
private final AuthArgumentResolver authArgumentResolver;

@Value("${cors.allowedOrigins}")
private String[] allowedOrigins;

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(authInterceptor)
Expand All @@ -40,8 +44,7 @@ public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers)
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
// todo 수정 필요
.allowedOrigins("*")
.allowedOrigins(allowedOrigins)
.allowedMethods(
PathItem.HttpMethod.OPTIONS.name(),
PathItem.HttpMethod.GET.name(),
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ kakao:
key: ${KAKAO_API_KEY:kakao}
seoul-public-parking-key: ${SEOUL_API_KEY:seoul}
pusan-public-parking-key: ${PUSAN_API_KEY:pusan}

# Allow origin
cors:
allowedOrigins: ${ORIGIN:http://localhost:3000}
3 changes: 3 additions & 0 deletions src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ pusan-public-parking-key: test

authcode:
expired-time: 60

cors:
allowedOrigins: http://localhost:3000
Loading