Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -5,8 +5,11 @@ import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vue 개발 서버(기본 5173)에서의 호출을 허용하기 위한 CORS 설정.
|
* CORS 설정.
|
||||||
* 운영 환경에서는 allowedOrigins 를 실제 도메인으로 제한하세요.
|
* - Vue 개발 서버(기본 5173)
|
||||||
|
* - Capacitor 안드로이드/iOS 앱 WebView 오리진 (capacitor://localhost, http(s)://localhost)
|
||||||
|
* 운영 웹은 Nginx 가 같은 도메인의 /api 로 프록시하므로 CORS 불필요.
|
||||||
|
* 별도 도메인에서 호출한다면 그 도메인을 allowedOrigins 에 추가하세요.
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class CorsConfig implements WebMvcConfigurer {
|
public class CorsConfig implements WebMvcConfigurer {
|
||||||
@@ -14,7 +17,12 @@ public class CorsConfig implements WebMvcConfigurer {
|
|||||||
@Override
|
@Override
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
registry.addMapping("/api/**")
|
registry.addMapping("/api/**")
|
||||||
.allowedOrigins("http://localhost:5173")
|
.allowedOrigins(
|
||||||
|
"http://localhost:5173", // Vue 개발 서버
|
||||||
|
"capacitor://localhost", // Capacitor (iOS scheme)
|
||||||
|
"https://localhost", // Capacitor Android (기본 https scheme)
|
||||||
|
"http://localhost" // Capacitor Android (http scheme)
|
||||||
|
)
|
||||||
.allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")
|
.allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")
|
||||||
.allowedHeaders("*")
|
.allowedHeaders("*")
|
||||||
.allowCredentials(true)
|
.allowCredentials(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user