kylepaulsen/ResourceOverride

Synchronous AJAX calls fail

MatthiasSchmalz opened this issue · 1 comments

Unfortunately the application where I'm trying to override resources is doing some AJAX calls synchronously. It looks like when I have specified redirect rules for such calls the request fails.
In network trace I just see "Failed".
Are synchronous AJAX calls not supported? Could this be enabled?

Cross origin requests seem to be a hard case to crack... I had some other issues reported earlier in this repo.
It seems like the way chrome actually tries to redirect requests is by sending the redirect status code to itself.
Upon looking up some info about synchronous cross origin ajax calls to a redirecting url, I found this: https://bugs.chromium.org/p/chromium/issues/detail?id=327014

It seems like chrome just wont do these kind of requests and I think that the rule you have set up fits this situation (the rule itself is a redirect). I'm not sure there's much you can do besides taking over the script as a whole... (which can be a pain, I know). You'd probably have to convert it to an async request. Another thing I learned recently is that chrome doesn't like redirecting cors requests that require a preflight options request (see here on how to avoid that: https://stackoverflow.com/questions/42168773/how-to-resolve-preflight-is-invalid-redirect-in-cors)