本地主机,因此没有允许访问 [英] localhost is therefore not allowed access
本文介绍了本地主机,因此没有允许访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要解决CORS问题,我写的有
To solve CORS issue, I wrote there
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With");
在我的服务器上的网站
但我在开发过程中,我看到了这个错误
but during my development I'm seeing this error
The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. Origin 'http://localhost' is therefore not allowed access.
我想允许原产地:*能解决一切吗?但为什么它说头包含多个值?
I thought allow-origin: * will solve everything? But why it says header contain multiple values?
推荐答案
这是一个普遍的问题时,意外地使CORS两次。检查以确保您没有启用它在Apache中,或者说,头不被设置两次。作为一个理智检查,你可以尝试删除页眉和添加你为你的回应之前就回来。
This is a common problem when accidently enabling CORS twice. Check to make sure you did not enable it in apache, or that the header is not being set twice. As a sanity check you can try to remove the header and add it right back before you serve out your response.
例如:
header_remove('Access-Control-Allow-Origin');
header('Access-Control-Allow-Origin: *');
这篇关于本地主机,因此没有允许访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文