[英]setupProxy file in CRA makes react-scripts start fail with Command failed with exit code 1 error
我根據文檔中的示例添加了以下 setupProxy 文件:
const proxy = require('http-proxy-middleware');
module.exports = function (app) {
app.use(
'/address',
proxy({
target: 'https://zip-cloud.appspot.com/api',
changeOrigin: true,
})
);
};
但是每當我想啟動 npm start 命令時,它都會失敗並顯示以下錯誤: error Command failed with exit code 1.
我不知道為什么它不起作用。 我正在使用最新的 CRA 版本,並且正在使用打字稿。 任何幫助都會受到贊賞!
嘗試:
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function (app) {
app.use(
'/address',
createProxyMiddleware({
target: 'https://zip-cloud.appspot.com/api',
changeOrigin: true,
})
);
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.