Is it possible to configure two different 404 pages in Next.js — one for rendered pages and another one for API routes? I want the 404 page for API calls to return in JSON format while for all other pages in HTML.
Yes it is possible just you have to create a wildcard page under the api page route. For example you can create a page page/api/[[...404]].js
. So, if no api route matches existing page it will show this page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With