在同一个域访问控制 - 允许 - 原产地问题 [英] Access-Control-Allow-Origin problems on the same domain

查看:120
本文介绍了在同一个域访问控制 - 允许 - 原产地问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

,当我试图从一个JavaScript文件位于完全相同的域中的Web服务,使一个XMLHTT prequest,我得到它是如何可能的:

产地 http://mydomain.com 不受访问控制 - 允许 - 产地??? <允许/ P>

如果我改变mydomain.com为localhost,我不再有问题,但我想保持它为mydomain.com

我有什么修改,为什么摆在首位,因为它是同一个域?

解决方案

1)在你的请求/响应头的样子。是服务器返回一个奇怪的的访问控制,允许原产地头?

2)这不只是域,它也是协议(HTTP VS HTTPS VS FTP等),端口(如果你有一个:8080或类似的东西),和潜在的后部分的.com /

How is it possible that when I try to make an XMLHTTPRequest from a javascript file to a web service located on the very same domain, I get:

Origin http://mydomain.com is not allowed by Access-Control-Allow-Origin ???

If I change mydomain.com to localhost, I no longer have problems, but I would like to keep it as mydomain.com

What do I have to edit, and why in the first place, since it's the same domain?

解决方案

1) look in your request/response headers. Is the server returning a weird access-control-allow-origin header?

2) It's not just the domain, it's also the protocol (http vs https vs ftp etc), the port (if you have a :8080 or something like that), and potentially the part after the .com/

这篇关于在同一个域访问控制 - 允许 - 原产地问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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