Commit 97834835 authored by 赵啸非's avatar 赵啸非

修改网关跨域

parent 6915ec9b
...@@ -68,8 +68,8 @@ public class WebLogAspect { ...@@ -68,8 +68,8 @@ public class WebLogAspect {
String startTime = map.getOrDefault("startTime", String.valueOf(System.currentTimeMillis())); String startTime = map.getOrDefault("startTime", String.valueOf(System.currentTimeMillis()));
long takeTime = (System.currentTimeMillis() - Long.parseLong(startTime)); long takeTime = (System.currentTimeMillis() - Long.parseLong(startTime));
log.info(" \n 请求路径:{} \n 耗时:{}ms \n 请求报文:{} \n 响应报文:{}" log.info(" \n 请求路径:{} 耗时:{}ms \n 请求报文:{} \n 响应报文:{}"
, request.getRequestURI(), takeTime, map.getOrDefault("req", ""), result == null ? "" : result.toString()); , request.getRequestURI(), takeTime, map.getOrDefault("req", ""), result == null ? "" : JSON.toJSONString(result));
} }
} }
......
...@@ -15,7 +15,7 @@ import org.springframework.context.annotation.Configuration; ...@@ -15,7 +15,7 @@ import org.springframework.context.annotation.Configuration;
* @author: zxfei * @author: zxfei
* @date: 2022/6/17 15:18 * @date: 2022/6/17 15:18
*/ */
@Configuration //@Configuration
public class AuthFilter { public class AuthFilter {
/** /**
......
...@@ -16,7 +16,7 @@ import java.util.regex.Pattern; ...@@ -16,7 +16,7 @@ import java.util.regex.Pattern;
* @author: zxfei * @author: zxfei
* @date: 2022/6/20 16:49 * @date: 2022/6/20 16:49
*/ */
@Component //@Component
public class BlackListUrlFilter extends AbstractGatewayFilterFactory<BlackListUrlFilter.Config> { public class BlackListUrlFilter extends AbstractGatewayFilterFactory<BlackListUrlFilter.Config> {
@Override @Override
public GatewayFilter apply(Config config) { public GatewayFilter apply(Config config) {
......
...@@ -32,7 +32,7 @@ import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.G ...@@ -32,7 +32,7 @@ import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.G
* @date: 2022/6/20 17:00 * @date: 2022/6/20 17:00
*/ */
@Slf4j @Slf4j
@Component //@Component
public class GlobalLogFilter implements GlobalFilter, Ordered { public class GlobalLogFilter implements GlobalFilter, Ordered {
@Autowired @Autowired
......
...@@ -16,6 +16,14 @@ spring: ...@@ -16,6 +16,14 @@ spring:
cloud: cloud:
# 网关配置 # 网关配置
gateway: gateway:
globalcors:
cors-configurations:
'[/**]':
allowedOrigins: "*"
allowedHeaders: "*"
allowedMethods: "*"
default-filters:
- DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST
httpclient: httpclient:
connect-timeout: 1000 connect-timeout: 1000
response-timeout: 5s response-timeout: 5s
......
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