Dynamic routes nextjs with status code 404

帅比萌擦擦* 提交于 2021-02-18 18:56:35

问题


I have a project with dynamic route like /[category]/[product]. After a client-side request via useRouter to graphql for example /hatchback/nissan/ returns a product with a code of 200, but if I make a request to /hatchback/nissan111/, I get an error because no such route exists and its response code still of 200 instead of 404. How can I check if a route exists and return a 404 status code during the component mount stage? I use SSR to achive this

来源:https://stackoverflow.com/questions/63877962/dynamic-routes-nextjs-with-status-code-404

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!