title: How to handle not found 404 for dynamic routes in Next.js which is calling API?
body: <p>I have a website which is developed by React and Next.js in client side and calls APIs from Asp.Net core server to fetch dynamic data such as products and categories.</p>
  <p>The issue is how to redirect to 404 not found page when I have undefined parameters in requested URL which needed to pass to API to get related data.</p>
  <p>For example, if the requested URL is https://domain/product/unique-title-of-product, &quot;unique-title-of-product&quot; will pass to API and responded data will show in product details page. But if the requested URL is &quot;https://domain/product/not-existed-title&quot;, how do I check this and redirect it to 404-not-found-page?</p>
  <p>I don't want to pass undefined-title to server because it will respond null or 200 or 500 internal server error if it is not handled. Then it seems I have to handle 404 redirect in client side without any server side interaction. But when I try to redirect with 404 status code in next.js, the status code will not to be reflected in browser.</p>
  <p>What is the best solution to handle this issue in client side?
  Or should I handle it server side?</p>