【发布时间】:2019-04-07 10:15:56
【问题描述】:
我用create-react-app创建了反应应用
所以支持的服务器侦听端口5000。 react 服务器监听端口3000。
我添加了这一行 "proxy": "http://localhost:5000" 来打包 JSON。
现在,当我提出这样的请求时:
GET /api/hello HTTP/1.1
Host: 192.168.0.102
Content-Type: application/json
到反应应用程序。我收到这条消息:
+IPD,420:HTTP/1.1 404 Not Found
X-Powered-By: Express
Content-Security-Policy: default-src 'self'
X-Content-Type-Options: nosniff
Content-Type: text/html; charset=utf-8
Content-Length: 148
Vary: Accept-Encoding
Date: Sat, 03 Nov 2018 11:18:11 GMT
Connection: keep-alive
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /api/hello</pre>
</body>
</html>
【问题讨论】:
标签: reactjs proxy backend create-react-app