diff --git a/src/main/java/store/itpick/backend/config/WebConfig.java b/src/main/java/store/itpick/backend/config/WebConfig.java index a2759d8..69af97d 100644 --- a/src/main/java/store/itpick/backend/config/WebConfig.java +++ b/src/main/java/store/itpick/backend/config/WebConfig.java @@ -11,6 +11,8 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; + import java.util.List; @@ -54,6 +56,17 @@ public void addCorsMappings(CorsRegistry registry) { .allowCredentials(true); } + @Override + public void addViewControllers(ViewControllerRegistry registry) { + // 모든 경로에서 index.html을 반환하도록 설정 + registry.addViewController("/{spring:\\w+}") + .setViewName("forward:/index.html"); + registry.addViewController("/**/{spring:\\w+}") + .setViewName("forward:/index.html"); + registry.addViewController("/{spring:\\w+}/**{spring:?!(\\.js|\\.css|\\.png|\\.jpg)$}") + .setViewName("forward:/index.html"); + } +