|
@@ -11,6 +11,7 @@ import org.springframework.core.env.Environment;
|
|
import org.springframework.web.cors.CorsConfiguration;
|
|
import org.springframework.web.cors.CorsConfiguration;
|
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
|
import org.springframework.web.filter.CorsFilter;
|
|
import org.springframework.web.filter.CorsFilter;
|
|
|
|
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
@@ -47,4 +48,17 @@ public class Config extends WebMvcConfigurerAdapter{
|
|
.excludePathPatterns("/device/**", "/admin/**", "/audio/search");
|
|
.excludePathPatterns("/device/**", "/admin/**", "/audio/search");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 允许跨域访问
|
|
|
|
+ * @param registry
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void addCorsMappings(CorsRegistry registry) {
|
|
|
|
+ registry.addMapping("/**")
|
|
|
|
+ .allowedOrigins("*")
|
|
|
|
+ .allowCredentials(true)
|
|
|
|
+ .allowedMethods("GET", "POST", "DELETE", "PUT")
|
|
|
|
+ .maxAge(3600);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|