【发布时间】:2021-08-01 21:26:38
【问题描述】:
前端是响应并请求服务器使用 Fetch 。
这样的代码。
fetch(`/ONETOWN/LARK/PACKAGE/STOCKOUT/LOAD_LIST_BY_TELL`,{
method: "POST",
headers: {
"Accept": "application/json",
"Content-Type": "application/json",
},
credentials: 'include',
body: JSON.stringify(info)
})
这样的后端(服务器)代码,cookie过期,所以我希望重定向到未经授权的页面。
static authentication(req,res) {
if(this.verifyCookie(req,res)) {
return true;
}
//res.status(401).end();
res.redirect('/#/page/unauthorized');
return false;
}
my Web don't redirect to the path i want,still stay the original page
如果重定向更改为位置方法 res.location('/#/page/unauthorized').end()
得到响应 200
【问题讨论】:
标签: node.js reactjs express fetch-api