javascript - -- 请求的资源上不存在 'Access-Control-Allow-Origin' header 。因此不允许访问 Origin 'http://localhost:8100'

标签 javascript angular laravel ionic-framework

尝试从提供商访问 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/

相关文章:

javascript - 动态创建的文本框中值的总和

javascript - 功能: Check value doesn't work

javascript - Angular 动态组件动画离开不起作用

javascript - 不使用 Material 的 Angular 8 分页自定义

php - 使用 Laravel 复选框一次更新多个记录

php - 如何从 laravel 的存储中删除图像?

javascript - 如何在 javascript 或 jQuery 中设置 select2(版本 3.5)下拉列表的 selectedindex

javascript - 与 IPFS 相比,JS-IPFS 的性能较低

html - 在模板 block 中使用不存在的主 html 标签的模板

laravel - 如何在共享主机中安装 Redis