NextJS 14 app router dynamic route returns the 404 page but with 200 status code, how to set the status code to 404 without removing the loading.tsx?
Following this question, I have a scenario in which I am fetching my agent (product) data from API by the agent slug, where the slug is dynamic. In NextJS 14 app router I am handling this with dynamic routes where the [slug] can be anything even an unlisted agent. When the agent doesn't exist, the API responds with error and the response.ok is false so I reject the promise, then the error message bubbles up in the app router to reach the error.tsx component. I have handled the situation partially by wrapping the fetch in a try/catch block and returning null if there is an error during the fetc
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.