Next.js Discord

Discord Forum

Unexpected 404s

Unanswered
Somali posted this in #help-forum
Open in Discord
SomaliOP
We have a NextJS app running on version 12.1.4 on multiple S3 buckets behind load balancer. We are simply running next build and serving it. -- not static with next export --

We are facing unexpected errors causing NextJS to display 404 page, mostly in in-app browsers and from Apple devices -- instagram, facebook, tiktok -- time to times. I have searched a lot but couldn't find any specific cause/solution for the error.

We had setup Sentry for tracking and the most obvious case that ends up with 404 is > SecurityError: The operation is insecure.

Important note:
The app is fully relies on dynamic routes based on the provided store code, we are displaying the content based on the store -- calling API to fetch store details etc by parsing the URL --. So we are using the <Link component as <Link href={/${store_code}/checkout} etc. We are not rendering the pages unless store details are fetched. All happening on client side, except for one single call on _app.tsx's getInitialProps to fetch SEO details of given store for crawlers, thats all.

Please see the screenshots below. Did any of you faced a similar problem, if so able to identify the root cause and solve it? Any help is highly appreciated. Thanks in advance.

0 Replies