I am trying to build a simple barebones node.js API using vercel. The structure of the project is like the following:
project-root/ ├── api/ │ ├── hello.js ← should map to /api/hello │ └── index.js ← should map to /api/index ├── package.json ├── vercel.json
Here is my environment:
$ node -v v20.19.0
$ vercel --version Vercel CLI 41.6.0 41.6.0
package.json
{ "name": "vercel-hello-verified", "version": "1.0.0", "type": "module"}vercel.json
{ "version": 2, "builds": [{ "src": "api/*.js", "use": "@vercel/node" }]}The content of hello.js
export default function handler(req, res) { console.log("📥 /api/hello was called"); res.status(200).json({ message: "Hello from Vercel!" });}
When I run "vercel dev" i get the api running at > Ready! Available at http://localhost:3000
But browsing the URL http://localhost:3000/api/hello given an error:
404: NOT_FOUNDCode: NOT_FOUNDID: dev1::lkub8-1744381659691-64bcbf88b31b
I have tried different options but nothing seems to work. This is a simple node API without any framework like express. Please help resolve.