|
|
@@ -3,18 +3,29 @@ package cn.iaun.it.config;
|
|
|
import cn.iaun.it.interceptor.TokenInterceptor;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
|
-// Web拦截器,用于认证
|
|
|
+// Web拦截器,用于认证+跨域
|
|
|
@Configuration
|
|
|
-public class InterceptorConfig implements WebMvcConfigurer {
|
|
|
+public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
|
|
|
@Override
|
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
|
registry.addInterceptor(getTokenInterceptor())
|
|
|
.addPathPatterns("/**")
|
|
|
.excludePathPatterns("/user/login");
|
|
|
+ WebMvcConfigurer.super.addInterceptors(registry);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addCorsMappings(CorsRegistry registry) {
|
|
|
+ registry.addMapping("/**")
|
|
|
+ .allowedHeaders("*")
|
|
|
+ .allowedMethods("*")
|
|
|
+ .allowedOrigins("*");
|
|
|
+ WebMvcConfigurer.super.addCorsMappings(registry);
|
|
|
}
|
|
|
|
|
|
@Bean
|