heroku express 服务器错误 503 "service unavailable"
heroku express sever error 503 "service unavailable"
我在 heroku 上创建了一个服务器(没有数据库),所有的 GET 请求都有效。但是,我有一个来自不同 heroku 域的 POST 请求失败并出现错误:503“服务不可用”
有人遇到过吗?
请求
let origin;
if (process.env.NODE_ENV === "development") {
origin = "http://localhost:5000/form";
}
if (process.env.NODE_ENV === "production") {
origin = "https://corsanywhere.herokuapp.com/https://cool-exercise-server.herokuapp.com/form";
}
const handleSubmit = async () => {
const response = await axios.post(origin, { value });
setResults((results) => [...results, ...response.data]);
};
错误:
xhr.js:177 POST https://corsanywhere.herokuapp.com/https://cool-exercise-server.herokuapp.com/form 503 (Service Unavailable)
createError.js:16 Uncaught (in promise) Error: Request failed with status code 503
heroku 日志 --tail:
heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/form" host=cool-exercise.herokuapp.com request_id=96c6ae17-7c6c-4ca8-ba21-30b5ba76e8e8 fwd="46.116.249.110" dyno=web.1 connect=1ms service=36ms status=503 bytes=0 protocol=https
后端请求处理程序:
app.post("/form", (req, res) => {
const { value } = req.body;
fs.createReadStream(path.normalize(value))
.pipe(csv({}))
.on("data", (data) => results.push(data))
.on("end", () => {
res.send(mergeData(results));
});
});
我的 post 请求中的问题是在服务器托管在 clowd 的 VM 中时试图访问本地文件。
我在 heroku 上创建了一个服务器(没有数据库),所有的 GET 请求都有效。但是,我有一个来自不同 heroku 域的 POST 请求失败并出现错误:503“服务不可用” 有人遇到过吗?
请求
let origin;
if (process.env.NODE_ENV === "development") {
origin = "http://localhost:5000/form";
}
if (process.env.NODE_ENV === "production") {
origin = "https://corsanywhere.herokuapp.com/https://cool-exercise-server.herokuapp.com/form";
}
const handleSubmit = async () => {
const response = await axios.post(origin, { value });
setResults((results) => [...results, ...response.data]);
};
错误:
xhr.js:177 POST https://corsanywhere.herokuapp.com/https://cool-exercise-server.herokuapp.com/form 503 (Service Unavailable)
createError.js:16 Uncaught (in promise) Error: Request failed with status code 503
heroku 日志 --tail:
heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/form" host=cool-exercise.herokuapp.com request_id=96c6ae17-7c6c-4ca8-ba21-30b5ba76e8e8 fwd="46.116.249.110" dyno=web.1 connect=1ms service=36ms status=503 bytes=0 protocol=https
后端请求处理程序:
app.post("/form", (req, res) => {
const { value } = req.body;
fs.createReadStream(path.normalize(value))
.pipe(csv({}))
.on("data", (data) => results.push(data))
.on("end", () => {
res.send(mergeData(results));
});
});
我的 post 请求中的问题是在服务器托管在 clowd 的 VM 中时试图访问本地文件。