No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'xxx' is theref

客官°小女子只卖身不卖艺 2023-06-27 14:58 108阅读 0赞

No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘xxx’ is therefore not allowed

解决方法:

第一种.如果重复设置了跨域,也就是tomcat或者nginx设置了跨域,服务代码也设置跨域那么设置就没效果了

第二种.使用spring的@CrossOrigin注解写在要跨越的类的上面,http://123.com和http://456.com是请求方的域名

@CrossOrigin(origins = {“http://123.com","http://456.com"\})

第三种.如果被请求方通过nginx代理,那么可以在nginx中配置文件中被请求方的server节点中添加:http://www.yayihouse.com/yayishuwu/chapter/2402

第四种.也可以在代码中添加过滤器:http://www.yayihouse.com/yayishuwu/chapter/2402

发表评论

表情:
评论列表 (有 0 条评论,108人围观)

还没有评论,来说两句吧...

相关阅读