Using path parameter on API of NextJS

Viewed 1829

I have a simple pages/api/thumbnail.js file with a handler:

export default async function handler(req, res) {
  console.dir(req.params)
  // ...
}

On a pure express server, it is possible to have a "path parameter", but on NextJS I got a error 404 if a try to pass some path on my API.

Example:

http://localhost:3000/api/thumbnail >> OK, it works

Now with a path:

http://localhost:3000/api/thumbnail/something >> ERROR, 404 not found!

Using NextJS API is it possible to use path parameters or only query string?

PS. I am using Vercel, if using a rewrite is the only solution, its acceptable to me.

1 Answers
Related