This is a fork of the next example api-routes-rest in the next repo.
There is a problem with query parameter parsing during a server request when a not encoded query parameter with a double // lose one / and is returned incorrect.
- Next 13.2.4 -> the problem does not appear
- Next 13.3.0 -> the problem appear for the first time
- if you run the code in development mode (yarn dev) you get the problem
- if you run the code in production mode (yarn build && yarn start) you do not get the problem
- Next 13.4.3 (latest) -> the problem appear in development and production mode (i didn't check from which version the problem went into production mode too)
API routes with REST
Next.js ships with API routes, which provide an easy solution to build your own API. This example shows how it can be used to create your REST API.
Deploy your own
Deploy the example using Vercel or preview live with StackBlitz
How to use
Execute create-next-app with npm, Yarn, or pnpm to bootstrap the example:
npx create-next-app --example api-routes-rest api-routes-rest-app
yarn create next-app --example api-routes-rest api-routes-rest-app
pnpm create next-app --example api-routes-rest api-routes-rest-app
Deploy to Vercel
Deploy it to the cloud with Vercel (Documentation).