I've added some apis in my project, but vercel cannot recognize?


As you see, I’ve deployed my project successfully, and my vercel.json is

{
  "rewrites": [
    {
      "source": "/(.*)",
      "destination": "/index.html"
    }
  ]
}

and this code in hello.cjs

module.exports = function (req, res) {
  res.status(200).send('Hello from Vercel Serverless Function (CommonJS)!');
};

when I requst my api, page shows:

Unexpected Application Error!
404 Not Found

It’s running in vercel dev. Only fail when deployed to prod.

Of cource in deployment I can see no functions injected, and also I’ve tried other js format: ts, js .etc
It always got fail.

I don’t know what happend? vercel env or my dependencies abnormal?

error url:
hello api

@vercel/node”: “2.10.3”,

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.

That vercel.json rewrite configuration is sending traffic from all paths, other than root, to www.whataicando.site/index.html which throws a 404. You’ll need to modify the rewrite to get this working