预检请求具有与原始请求不同的URL

时间:2018-08-22 13:17:54

标签: javascript cors xmlhttprequest preflight

我正在使用HEAD和GET请求从(托管)JavaScript进行调用。请求的来源位于子域地址上,并且仅为此子域设置了Access-Control-Allow-Origin。我使用“ https://subdomain.domain.com/request/path”模式对请求的URL进行了硬编码,但实际上是在不带子域“ https://example.com/request/path”的情况下在预检中请求OPTIONS,导致401和Failed to load ***address without subdomain***: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '***origin WITH subdomain***' is therefore not allowed access.的结果接下来我什至感到陌生从HEAD和GET方法获得302个结果,该结果发送到带有子域的正确URL。为什么此ULR会不断变化,我该如何解决?

0 个答案:

没有答案