AJAX及API在IE10中异常,跨域请求Header问题求助
xxx Not in Access-Control-Allow-Headers Hey Dylan, I’ve run into this exact IE10 quirk a few times—let’s walk through the most likely fixes since your backend is already configured correctly for modern browsers.
Check for whitespace or formatting issues in your backend header
IE10 is extremely strict about the format ofAccess-Control-Allow-Headers. If your backend returns the header with extra spaces (e.g.,Access-Control-Allow-Headers: xxx, Content-Typeinstead ofAccess-Control-Allow-Headers: xxx,Content-Type) or inconsistent capitalization, IE10 will reject it. Double-check that the header value matches the exact name of yourxxxrequest header, including case.Verify the OPTIONS preflight response in IE10
Modern browsers handle CORS smoothly, but IE10 sometimes sends OPTIONS preflight requests with unexpected header formatting. Use a tool like Fiddler to capture the OPTIONS request from IE10 and confirm that the response’sAccess-Control-Allow-Headersexplicitly includesxxx. It’s possible your backend is returning the header for regular requests but not for OPTIONS preflights (some frameworks require explicit configuration for OPTIONS).Clear IE10’s CORS preflight cache
IE10 aggressively caches the results of CORS preflight requests. If you recently addedxxxto your allowed headers, IE10 might still be using an old cached response that doesn’t include it. Clear the browser’s cache completely, or add aCache-Control: no-cacheheader to your OPTIONS response to prevent future caching issues.Ensure no proxy or middleware is modifying the header
If you’re using a reverse proxy (like Nginx) or any middleware between your frontend and backend, it might be stripping or modifying theAccess-Control-Allow-Headersheader before it reaches IE10. Check your proxy configuration to make sure it’s passing through the header unchanged.
Hopefully one of these fixes gets your API working in IE10—let me know if you need to dig deeper into any of these steps!
内容的提问来源于stack exchange,提问作者Dylan

