在同一个域访问控制 - 允许 - 原产地问题原产地、访问控制、问题、在同一个

2023-09-10 19:36:00 作者:毁我现在废你未来〃

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

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

如果我改变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:

域策略 1 限制域用户允许登录的设备和时间

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/

 
精彩推荐
图片推荐