后端302到angular-ui-router对应的路径时无效

// node express
res.redirect(302, 'http://myweb.com/app/');

我的登录和/app是两套angular应用,我想实现在登录成功之后,后端302重定向到/app页面,但是没成功。

报错:

A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'null' is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute.

求助,如何解决呢?

阅读 3.4k
2 个回答

这个错报的是跨域,通常来讲这样就可以解决了

res.header("Access-Control-Allow-Origin", "*");

但是 the credentials flag is true 意味着你还有传递数据的需求,比如cookie等,那么这个时候的跨域头设置禁止为通配符,得这样:

res.header("Access-Control-Allow-Origin", "http://myweb.com:8080");

啥都不说了,来文档吧:
https://developer.mozilla.org...

'Access-Control-Allow-Origin' 跨域了。
楼主要保证 redirect 重定向的域与当前域是一致,否则那就使用 jsonp 或者其它方式来解决跨域问题吧。
域名问题解决方式

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题