最近遇到一个跨域问题,后端解决方案一般就是加注解或者写个跨域类,一些常规的解法网上已经说了很多了
可以看这篇博客的三种常规解决办法
https://blog.csdn.net/m0_56736359/article/details/123521926
来说两个其他博客不常见的解决办法
一.网关yml配置,适合SpringBoot项目
server:
port: 9999
spring:
application:
name: api-gateway
cloud:
nacos:
server-addr: xxxxxx:8848
gateway:
globalcors: # 跨域配置处理
cors-configurations:
'[/**]':
allowedOrigins: "*"
allowedMethods: "*"
allowedHeaders: "*"
二.直接用跨域浏览器本地测试



