javascript - Share credentials with cross domain script tag in Firefox -
suppose i've authorized in domain boo.com
, have session:
s:x2gyrvxggmsffwx7gdbkxmwb.4bdxlpmasqd9hgetkbdx3z4teczjec50gnrh5bc+kwu
what want add script tag domain foo.com
, points boo.com
:
<script src='http://boo.com/blah.js'></script>
in browsers including safari , google chrome, script tag sets cookie value in http headers doesn't work in firefox.
firefox doesn't set cookie headers unauthorized
error server. problem?
update:
i enabled cors in server-side problem still exist in firefox:
app.use(function (req, res, next) { // website wish allow connect res.setheader('access-control-allow-origin', 'http://foo.com'); // request methods wish allow res.setheader('access-control-allow-methods', 'get, post, options, put, patch, delete'); // request headers wish allow res.setheader('access-control-allow-headers', 'cookie'); // set true if need website include cookies in requests sent // api (e.g. in case use sessions) res.setheader('access-control-allow-credentials', true); // pass next layer of middleware next(); });
here solution:
<script src="http://boo.com/blah.js" crossorigin="anonymous"></script>
read more here: http://blog.errorception.com/2012/12/catching-cross-domain-js-errors.html
Comments
Post a Comment