尝试从提供商访问 http:Localhost:9000/api/post
时出现此错误
Failed to load http://127.0.0.1:8000/api/post: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access. is therefore not allowed access
任何人都知道哪里出了问题。
最佳答案
您的前端和后端位于不同的端口,这意味着您的 ajax 请求受跨源安全性的约束。
您需要通过添加在后端 api(服务器端)进行更改
访问控制允许来源:“*”;
根据您使用的语言在响应 header 中使用 php、java 或 python 等
关于javascript - -- 请求的资源上不存在 'Access-Control-Allow-Origin' header 。因此不允许访问 Origin 'http://localhost:8100',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49094175/