Skip to content

Commit

Permalink
Merge pull request #233 from ShallWeProject/infra/232-cors-setting
Browse files Browse the repository at this point in the history
 infra: cors설정
  • Loading branch information
leeseunghakhello authored Jan 22, 2024
2 parents e36b343 + 0d3636c commit 5c1faf5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/java/com/shallwe/global/config/WebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.shallwe.global.config;

import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@RequiredArgsConstructor
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**") // url 패턴
.allowedOriginPatterns("*")
// todo: server url 생성 시 변경 필요
// .allowedOrigins("url:8080", "http://localhost:8080")
.allowedMethods(HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PATCH.name(), HttpMethod.DELETE.name(), HttpMethod.OPTIONS.name(),
HttpMethod.HEAD.name(), HttpMethod.TRACE.name(), HttpMethod.OPTIONS.name()) // 허용 method
.allowedHeaders("Authorization", "Content-Type"); // 허용 header
}
}

0 comments on commit 5c1faf5

Please sign in to comment.