【发布时间】:2019-12-11 08:02:27
【问题描述】:
我已通过代理对我的节点 js 服务器 http://localhost:3000 和 http://localhost:9000 做出反应
在我的 package.json 反应应用中:
...
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:9000",
...
一些请求错误的作品。
例子:
我在我的反应应用程序上http://localhost:3000/admin 并创建对服务器的请求
fetch('admin/check-token',
{
method: "GET",
headers: {
'Content-Type': 'application/json',
'Authorization':Cookie.getCookie(TOKEN)
},
})
.then(response => {
return response.json();
})
.then((json) => {
console.log(json)
})
.catch(function (res) {
console.log(res)
})
我需要向http://localhost:9000/admin/check-token 提出请求,但我有错误,Chrome 显示我向http://localhost:9000/admin/admin/check-token 发送请求。
据我了解,额外的/admin 取自http://localhost:3000/admin。
我做错了什么?
【问题讨论】:
标签: node.js reactjs proxy request