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

查看:75
本文介绍了javascript - 后端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.

求助,如何解决呢?

解决方案

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

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...

这篇关于javascript - 后端302到angular-ui-router对应的路径时无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆