Getting an weird error in production which is not happening in localhost #68072
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Are you using the Also, could you change this part: action={async (formData) => {
await formAction(formData);
}} to action={formAction} |
Beta Was this translation helpful? Give feedback.
-
The problem you are facing is due to static rendering of not-found.js. Next.js thinks your page doesn't need to fetch or upload data if you don't use a dynamic function. This means it shows the same page to everyone, and any outgoing request can't be run because the page is delivered as static HTML from a CDN or edge server. So, to solve this issue: // app/not-found.js
import {headers} from "next/headers";
export default async function NotFound() {
// sweet trick make the page into dynamic rendering
const headersList = headers()
return (
<Custom404 />
)
} Put your logic of the 404 page inside a Custom404 component. Hope it resolves your issue. |
Beta Was this translation helpful? Give feedback.
The problem you are facing is due to static rendering of not-found.js.
Next.js thinks your page doesn't need to fetch or upload data if you don't use a dynamic function. This means it shows the same page to everyone, and any outgoing request can't be run because the page is delivered as static HTML from a CDN or edge server.
So, to solve this issue:
Put your logic of the 404 page inside a Custom404 component.
Mark the Custom404 page as "use client".
Hope it …