404 (Not Found) on POST

I have been deploying my projects to vercel for weeks now and the authentication works on localhost and updates to MongoDB but it gives error on our Live vercel website

I can’t submit forms and newsletters on the vercel site which seems to work fine on localhost with no errors and updates to the mongoDB websites online.
Error on clicking the buttons:

mail-script.js:116 
  (2) POST https://ihype.vercel.app/api/getMsgIp 404 (Not Found)

It works fine on localhost with no errors, but not on the vercel site: Ihype Company | HypeReach, Contact Us

my routes:

app.post('/api/getIp', async (req, res) => {
 await main(
   (func = 'limitFindMany'),
   (database = 'ihypeBeta'),
   (collection = 'betaNewsTesters'),
   (data = req.body),
   (limit = 1)
 )
   .catch(console.error)
   .then(() => {
     if (array[0] !== undefined && array[0] !== null) {
       res.json({
         present: true,
         data: array[0],
       })
     } else {
       res.json({
         present: false,
       })
     }
   })
})


app.post('/api/getMsgIp', async (req, res) => {
 await main(
   (func = 'limitFindMany'),
   (database = 'ihypeBeta'),
   (collection = 'betaTesters'),
   (data = req.body),
   (limit = 1)
 )
   .catch(console.error)
   .then(() => {
     if (array[0] !== undefined && array[0] !== null) {
       res.json({
         present: true,
         data: array[0],
       })
     } else {
       res.json({
         present: false,
       })
     }
   })
})

HTML, CSS, JAVASCRIPT, NODEJS, EXPRESS, MONGODB

There’s another community post with 404 debugging tips that might be helpful. Please give these solutions a try and let us know how it goes.

A human should be around soon to offer more advice. But you can also get helpful information quickly by asking v0.

If you’re having trouble deploying an Express app, this guide can help.

You can also ask v0 for suggestions tailored to your own project setup.

Hi @ohaekimdaniel-gmailc! Welcome to the Vercel Community :wave:

Are there any helpful error logs that you can share with us?

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.