Skip to content

Commit

Permalink
Merge pull request #81 from DEPthes/feat/#80-cors
Browse files Browse the repository at this point in the history
[FEAT]: 프론트 로컬 cors 설정
  • Loading branch information
phonil authored Aug 15, 2024
2 parents 4e96be8 + 6a5090e commit 03dbb76
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/main/java/mvp/deplog/global/config/WebMvcConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package mvp.deplog.global.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

private final long MAX_AGE_SECS = 3600;

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

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins(allowedOrigins)
.allowedOriginPatterns()
.allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")
.allowedHeaders("*")
.allowCredentials(true)
.maxAge(MAX_AGE_SECS);
}
}

0 comments on commit 03dbb76

Please sign in to comment.