安全扫描修复
This commit is contained in:
parent
3214250e09
commit
5e83e5dbdd
|
|
@ -1,7 +1,9 @@
|
||||||
package com.bonus.gateway.config;
|
package com.bonus.gateway.config;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.alibaba.nacos.common.utils.JacksonUtils;
|
||||||
import com.bonus.gateway.config.properties.CorsProperties;
|
import com.bonus.gateway.config.properties.CorsProperties;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
@ -14,6 +16,7 @@ import org.springframework.web.util.pattern.PathPatternParser;
|
||||||
* Description: 全局跨域配置
|
* Description: 全局跨域配置
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@Slf4j
|
||||||
public class GlobalCorsConfig {
|
public class GlobalCorsConfig {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CorsProperties corsProperties;
|
private CorsProperties corsProperties;
|
||||||
|
|
@ -24,6 +27,7 @@ public class GlobalCorsConfig {
|
||||||
// 允许所有的HTTP请求方法(GET, POST, PUT, DELETE等)
|
// 允许所有的HTTP请求方法(GET, POST, PUT, DELETE等)
|
||||||
config.addAllowedMethod("*");
|
config.addAllowedMethod("*");
|
||||||
// 允许所有的域名发起的请求 比如http://localhost:8080、
|
// 允许所有的域名发起的请求 比如http://localhost:8080、
|
||||||
|
log.info("允许的域名:{}", corsProperties.getAllowedOrigins());
|
||||||
if(CollUtil.isNotEmpty(corsProperties.getAllowedOrigins())) {
|
if(CollUtil.isNotEmpty(corsProperties.getAllowedOrigins())) {
|
||||||
for(String cors : corsProperties.getAllowedOrigins()) {
|
for(String cors : corsProperties.getAllowedOrigins()) {
|
||||||
config.addAllowedOrigin(cors);
|
config.addAllowedOrigin(cors);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue