“Access-Control-Allow-Origin"标头的值不等于提供的原点 [英] The 'Access-Control-Allow-Origin' header has a value that is not equal to the supplied origin

查看:23
本文介绍了“Access-Control-Allow-Origin"标头的值不等于提供的原点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 ajax 登录 API,但出现此错误:

I am trying to login with ajax to an API and I get this error:

XMLHttpRequest 无法加载.'Access-Control-Allow-Origin' 标头具有不等于提供的原点的值.起源'http://localhost' 因此不允许访问.

XMLHttpRequest cannot load. The 'Access-Control-Allow-Origin' header has a value that is not equal to the supplied origin. Origin 'http://localhost' is therefore not allowed access.

我在互联网上阅读了有关此错误的所有信息,并且尝试了所有可以在网上找到的解决方案.我根据此处的 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!

推荐答案

You must set Access-Control-Allow-Origin header to * or指定值 http://localhost

You have to set Access-Control-Allow-Origin header to * or specified value http://localhost

您可以通过:

1- 您的代码

2- .htaccess 文件

2- .htaccess file

3- 服务器配置(需要重启网络服务器)

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"标头的值不等于提供的原点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆