Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery ajax call to domain that redirects to another domain (isn't followed)

This is sort of a cross-domain issue, but the problem is the browser (Chrome) doesn't seem to follow the redirect. Instead, nothing is returned to the jQuery ajax call, and I get an error.

I'm trying to use jQuery.ajax, but the URL that I'm using redirects to another domain. When this happens, I get an error. Is there anything special that needs to be done so the browser will follow the redirect?

I already added access-control-allow-origin: * to the header of the second domain that is being redirected to.

like image 542
Biagio Arobba Avatar asked Apr 11 '12 20:04

Biagio Arobba


1 Answers

An HTTP redirect page is treated as any other HTTP page in that it also needs the access control headers. If your redirect page does not have them, the browser will never get around to checking if the page being redirected to has the proper permissions.

Along with the Location header on the redirect page, also add the Access-Control-Allow-Origin header and its related constituents (i.e. Access-Control-Allow-Methods etc.)

like image 119
BigMacAttack Avatar answered Oct 18 '22 21:10

BigMacAttack