- 请求的资源上没有“Access-Control-Allow-Origin”标头。因此不允许Origin'http:// localhost:8100'访问

问题描述 投票:4回答:1

当试图从提供者访问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

任何人都知道什么是错的。

javascript angular laravel ionic-framework
1个回答
2
投票

您的前端和后端位于不同的端口上,这意味着您的ajax请求受到跨源安全性的约束。

您需要通过添加在后端api(服务器端)进行更改

Access-Control-Allow-Origin:“*”;

根据你使用php,java或python e.t.c的语言在响应头中。

© www.soinside.com 2019 - 2024. All rights reserved.