Home > Blockchain >  Vercel When I use POST routes I get 404 error
Vercel When I use POST routes I get 404 error

Time:10-13

I have node js on the vercel but When I uncomment this code I get a 404(not found) error, why did this happen? I have also GET routes but this works fine

   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);

please consider that POST routes function I have separately!!!

CodePudding user response:

friends, I solved this problem, you should create vercel.json file in the project file and write this

{
    "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)"
      }
    ]
  }

if you have internal error 500 you should to go project dashboard then you should click "FUNCTIONS" and there you will find the Error button Clicking there will show what error you have in your files.

  • Related