问题描述
我试图用ajax登录到API,但出现此错误:
I am trying to login with ajax to an API and I get this error:
我在Internet上都阅读了有关此错误的所有信息,并且尝试了所有可以在网上找到的解决方案.我根据此处的CORS说明修改了.htaccess和apache httpd配置文件: http://enable-cors.org/server_apache.html
I read all about this error, all over the internet, and I've tried all the solutions I could find online. I modified the .htaccess and apache httpd configuration file according to the CORS instructions here: http://enable-cors.org/server_apache.html
Access-Control-Allow-Origin: *
似乎没有任何作用.如果你们能帮我解决这个问题,我将不胜感激.谢谢!
Nothing seems to be working. I'd really appreciate if you guys can help me out with this. Thank you!
推荐答案
您必须将 Access-Control-Allow-Origin标头设置为*或指定值 http://localhost
You have to set Access-Control-Allow-Origin header to * or specified value http://localhost
您可以通过以下方式完成此操作:
You can do this through:
1-您的代码
2- .htaccess文件
2- .htaccess file
3-服务器配置(需要重新启动Web服务器)
3- Server config (restart web server required)
以下是显示如何在apache上进行操作的链接
Here is the link that show how to do it on apache
http://access-control-allow-origin-guide.com/enable-cors-on-apache-linux/
这篇关于"Access-Control-Allow-Origin"标头的值不等于提供的来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!