Handling redirections
@Mihaiii created an issue in https://github.com/Starcounter/Home/issues/272 that shows how developers can be confused by Palindrom's handling of the response header for the patch request.
- When Palindrom receives
Locationheader in the response to theapplication/json-patch+jsonrequest, should it change the URL in the address bar to the value of that header? - If the answer to the above question is yes, should Palindrom issue an HTTP GET
application/json-patch+jsonrequest to that location, similarly how it does with<palindrom-redirect>? - @alshakero Can Palindrom actually read the
Locationheader in XHR callback in all browsers or is it among the headers obscured for security reasons?
cc @miyconst
If the answer to the above question is yes, should Palindrom issue an HTTP GET
application/json-patch+jsonrequest to that location, similarly how it does with<palindrom-redirect>?
Investigating the original issue I found that browser automatically sends request to the new location, not sure how Palindrom can intercept this.
When Palindrom receives
Locationheader in the response to the...
I think, the decisive factor here is the response status code, not the header. It should be 301 or 302 which means that resource has been moved.
Anyway, I am not sure what should be the correct behavior.
When Palindrom receives Location header in the response to the application/json-patch+json request, should it change the URL in the address bar to the value of that header?
Apparently, Palindrom will never receive this header. The browser redirects when it sees it on a lower level. even when status is 200. I tested this:
Paste this:
<?php
header("Location: https://www.youtube.com/embed/UgUgz4T3_wc", true, 200);
?>
here: http://phpfiddle.org/# (doesn't support permalinks).
If the answer to the above question is yes, should Palindrom issue an HTTP GET application/json-patch+json request to that location, similarly how it does with
?
I don't think Palindrom in relevant here. When you access http://someStarCounterApp.com and you see Location header you'd redirect before any JS is executed. I hope I understand the issue correctly.
@alshakero Can Palindrom actually read the Location header in XHR callback in all browsers or is it among the headers obscured for security reasons?
I am not giving up on it that easily :) Can Palindrom obtain the URL from xhr.responseURL then?