fetch跨域问题

Fetch API cannot load
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:5000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

同样的ajax,get可以用,但是post就会出现这种问题

阅读 8.5k
3 个回答

协调后端解决,不同语言设置Access-Control-Allow-Origin的方式不同。

可以通过设置代理解决跨域问题

clipboard.png

发送ajax 的所在域名和目标服务器的是同域吗?如果不是的话就是你的服务器端允许了get 的跨域访问,而post没有,可以尝试设置服务器端允许所有访问。
也可以尝试在ajax请求是增加一些option试试,具体可以参考
https://stackoverflow.com/que...

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题