Skip to content

Commit

Permalink
fix: add cors configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
aiaiaiai1 committed Jun 2, 2024
1 parent 740383a commit 615fec1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/gymmi/global/WebMvcConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;
Expand All @@ -12,8 +13,17 @@
@RequiredArgsConstructor
public class WebMvcConfig implements WebMvcConfigurer {

private static final String ALLOWED_METHOD_NAMES = "GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH";

private final LoginedUserResolver loginedUserResolver;

@Override
public void addCorsMappings(final CorsRegistry registry) {
registry.addMapping("/**")
.allowedMethods(ALLOWED_METHOD_NAMES.split(","))
.allowedOrigins("*");
}

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(loginedUserResolver);
Expand Down

0 comments on commit 615fec1

Please sign in to comment.