Chrome在CORS预检上发出两个OPTIONS请求

时间:2018-01-03 16:28:38

标签: ajax google-chrome cors

在执行需要预检的CORS请求时,它们无法在我们的网络上运行。而不是Chrome发出两个请求var rIcon = { url: 'static/rdot.svg', scaledSize: new google.maps.Size(50, 50), // scaled size 16 px origin: new google.maps.Point(0,0), // origin anchor: new google.maps.Point(0, 0) // anchor }; <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="150" height="150" viewBox="0 0 500 500"> <metadata><?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c142 79.160924, 2017/07/13-01:06:39 "> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about=""/> </rdf:RDF> </x:xmpmeta> <?xpacket end="w"?></metadata> <defs> <style> .cls-1 { fill: #bf311a; stroke: #fff; stroke-linejoin: round; stroke-opacity: 0.7; stroke-width: 38px; opacity: 0.9; } </style> </defs> <circle class="cls-1" cx="250" cy="250" r="210"/> <image x="198" y="122" width="104" height="256" xlink:href="data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB8AAABNCAQAAAD04XdOAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAKqNIzIAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfhDB0JDDDz8kTrAAADG0lEQVRYw+2YO0wUQRjHf7P34oBDBI7jTfBBPK00xppCTUwsbNQYqey1sbC1sNFCiSRWFhoSC2MhMbG38JEYCwMBDAF8cDyO8IbzXrtrccexu7Pg7NFI4tds5r/zm/nm29nZ71thfqSTZXY3DZN55vnGZ95ibN8Q5hwxsvzdgsXrKPd5vo2PcIglBRzAxEcM6OfWllteTGCQYIWb3CgHLxCb5HhEtDwcNJLU0FsuDgI4C+CXbuVpwWdT1lh3TCPIEKeGNb80bi2DfCUAQI5GjnKKVhIIhKVfikY6GJbxCM94Y9PiPKGHaZtPeWppYdht7fWO9igXSDhUA0HMPXRCUtI8JuzAoVM98h8wpTAb6vgUSSocmq6OzzBFlbxIVdzEkPoe9rLr5DMh7AX/JSl5L3jQTSzvlfkXcG1vuLk3fHJveMoLrkuK3wsekBRPoetyE9VxIXET6niQavKOwTyErp4OUpa2jywL6vhxGkhb2hUs7uT8uot2B2zOV/KTpNtXxqCN+tK5lqWOOL2cY84SPBPBMLh93wU6mdLbnSNCAzBrO6wETVzlpdvsOpXUlRIQjRxJdKzLNGgmwSC44RppW5DkxYXRuEvGHd/NBBrNQB9PC4I6bhCkihCT9NO3JarigmqGeM17PlllVdwkR4zzHKGbAczSqNKDM6ikohh5gUGKPAIwCBAhDIxxhaGdcOtz1wnQQp7Zkpcm0MIycebdnNeIcpuB4q7LU0EP92hlpphbCGCaNh5y3W12jRiXeWUb8hhfyLNh2bSVRDjBmPsrE3G0x3hAjU3ZQONSYTYVe0HalpwI4Iw6Ps4QB2y4QaeX9GDE0TNNlKg6PuFop6mjSR1fwH7W+siRVsc3HXiOai953Xd0W1Kq4+egOi5c2tny8aLt39zmP74P8AC+7dPdO75B2q2vKv6DBULl40FC1p8OgKdKapUlafagOr7Cog3X8VhJrUqKzws+LimxvRViXV7wBPbevzlJjTo+RsaW06/Tzmk/dYQspb0GUqVcsFGStFv+L5nANT9TGJb6VKPJJcYAGd5xkRmL0kD3Hxf8zaNEFOrVAAAAAElFTkSuQmCC"/> </svg>,它会触发两个完全相同的OPTIONS个请求,最终会出现以下错误:

PUT

深入研究这个问题,有两件事情很突出。

  1. 如果我在Chrome开发者工具的“网络”部分启用“限制”,则可以正常运行,OPTIONS请求后跟XMLHttpRequest cannot load http://server/api/foo. Response for preflight is invalid (redirect)
  2. 在时间标签下,它几乎就像是试图同时触发两个(First requestSecond request)同时请求。尽管请求在稍后排队,但“开始时间”显示它与初始OPTIONS请求的请求相同。
  3. comparison的限制工作和非工作请求看起来非常相似。

0 个答案:

没有答案