首页 > 解决方案 > 为什么我无法从运行在端口 3000 上的 React 应用程序访问运行在端口 3001 上的节点服务器?

问题描述

我正在尝试3001从运行在端口 3000 上的反应应用程序访问在端口上运行的 API,但出现以下错误:

Proxy error: Could not proxy request /%3Canonymous%3E from localhost:3000 to http://localhost:3001/.

我有以下内容package.json

"proxy": "http://localhost:3001",

标签: node.jsreactjs

解决方案


同时启动前端和后端,如:previous- "dev": "concurrently \"npm run client\" && \"npm run server\""

并将其更改为 "dev": "concurrently \"npm run client\" \"npm run server\""

否则将代理更改为“ http://localhost:3001 ”而不是“ https://localhost:3000


推荐阅读