Vercel当我使用POST路由时,我得到404错误



我在vercel上有node js,但当我取消注释此代码时,我得到了一个404(未找到(错误,为什么会发生这种情况?我也有GET路线,但这很好

const { registration, authorization, logOut, recoveryPassword, changePassword } = require('../controllers/userAuth');

server.post('/registration', registration);
server.post('/authorization', authorization);
server.post('/logout', logOut)
server.post('/recovery-password', recoveryPassword);
server.post('/change-password/:token', changePassword);

请考虑我单独拥有的POST路由功能!!!

朋友们,我解决了这个问题,你应该在项目文件中创建vercel.json文件并编写这个

{
"version": 2,
"builds": [
{
"src": "./app.js" (It may be another name but this file should listen to the server)",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "/app.js (It may be another name but this file should listen to the server)"
}
]
}

如果你有内部错误500,你应该去项目仪表板,然后你应该点击";功能;在那里你会发现错误按钮点击那里会显示你的文件中有什么错误。

最新更新