404 error when using vercel dev for simple node api

Including the file extension serves the file. Actually I was able to resolve this by adding routes to the configuration. Here’s the updated configuration that works:

vercel.json

{
  "version": 2,
  "builds": [{ "src": "api/*.js", "use": "@vercel/node" }],
  "routes": [
    { "src": "^/api/hello$", "dest": "/api/hello.js" },
    { "src": "^/api/test$", "dest": "/api/test.js" },
    { "src": "^/api/.*$", "dest": "/api/index.js" }
  ]
}
2 Likes