Skip to content

Commit

Permalink
Merge pull request #235 from ShallWeProject/develop
Browse files Browse the repository at this point in the history
main <- develop
  • Loading branch information
leeseunghakhello authored Jan 22, 2024
2 parents 63cf3e2 + 5c1faf5 commit bdef036
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 bdef036

Please sign in to comment.