当试图从提供者访问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(服务器端)进行更改
Access-Control-Allow-Origin:“*”;
根据你使用php,java或python e.t.c的语言在响应头中。