laravel -- 请求的资源上不存在“Access-Control-Allow-Origin”标头。因此不允许访问源 'http://localhost:8100'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49094175/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
-- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access
提问by zainudin noori
while trying to access http:Localhost:9000/api/post
from provider i get this error
在尝试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
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
any knows what is wrong.
任何人都知道出了什么问题。
回答by ankit bhardwaj
Your front and back end are on different ports which means your ajax requests are subject to cross origin security.
您的前端和后端位于不同的端口上,这意味着您的 ajax 请求受到跨源安全性的约束。
You need to do changes at your back-end api (server side) by adding
您需要通过添加在后端 api(服务器端)进行更改
Access-Control-Allow-Origin: "*";
访问控制允许来源:“*”;
in response headers according to the language you are using php,java or python e.t.c.
根据您使用的语言在响应头中使用 php、java 或 python 等