node.js - 为什么我无法从运行在端口 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",
解决方案
同时启动前端和后端,如:previous- "dev": "concurrently \"npm run client\" && \"npm run server\""
并将其更改为 "dev": "concurrently \"npm run client\" \"npm run server\""
否则将代理更改为“ http://localhost:3001 ”而不是“ https://localhost:3000 ”
推荐阅读
- android - Create Folder in External Android Storage (nativescript)
- android - when selected add border shape for textView and editText ,
- php - 网页是否有 pcntl_exec
- node.js - PM2 日志轮换每周配置
- mariadb - 在 Windows WSL 上将文件导入 MariaDB
- c# - Get column and row of count from GridLayoutGroup programmatically
- python - Python3:与玩家碰撞时从动态数组中删除敌人
- c++ - 在 C++ 中使用开始时间和持续时间计算活动任务
- javascript - Electron ipcRenderer message between two windows doesn't work
- python - ta-lib MACD 函数在封闭的 100 个数字示例上计算错误