Commit 914a09b3 authored by zengtianlai3's avatar zengtianlai3

修改CORS跨域资源共享

parent dce5bfa8
......@@ -3,6 +3,7 @@ package iot.sixiang.license.config;
import iot.sixiang.license.jwt.AuthenticationInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;
......@@ -14,11 +15,17 @@ public class CorsConfig implements WebMvcConfigurer {
@Autowired
AuthenticationInterceptor authenticationInterceptor;
@Value("${cros.cros_allowed_origins}")
private String[] allowedOrigins;
@Value("${cros.cros_allowed_method}")
private String[] allowedMethods;
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("*")
.allowedOrigins(allowedOrigins)
.allowedMethods(allowedMethods)
.allowCredentials(true)
.maxAge(3600)
.allowedHeaders("*");
......
......@@ -12,3 +12,7 @@ logging:
server:
tomcat:
port-header: HEAD,PUT,DELETE,OPTIONS,TRACE,COPY,SEARCH,PROPFIND
cros:
cros_allowed_origins: http://192.168.1.88:8080, http://localhost:8868
cros_allowed_method: GET,POST
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment