Skip to content

res.redirect behaves differently if the request type is xhr/Redirect (vs document) #6281

Closed Answered by krzysdz
stefango asked this question in Q&A
Discussion options

You must be logged in to vote

You can't do anything more on the server. If you perform a fetch() or XHR then the request is handled separately from document navigation. If a redirect is received in response to such request then only the request is redirected.

Let's say that you have a page A which fetches some information client-side from resource B (http://b.b/b). It's an old page and uses HTTP instead of HTTPS. Then someone managing B decides to upgrade to HTTPS and always issues redirects to the same resource, but using HTTPS (https://b.b/b) when asked over HTTP.
Now, what will happen is that when a user loads A it makes a request to B that gets redirected by the server to use HTTPS, they will still be on A which w…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by stefango
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants