Open agustingabiola opened 3 months ago
Even if the not-found
component is server-side, after the redirect to the page, the entire window.__ENV
becomes undefined
, and env("ENV_KEY")
also becomes undefined
.
fixes with changing router.push() to window.location.href without page refresh it works as expected
only happens from navigation from not-found page
@agustingabiola Hi! Since my PR #150 hasn't received a response, I've published my fork on npm.
You can switch to awesome-next-runtime-env
and be sure to configure the strategy
prop for the assignment in your Root Layout:
<head>
<PublicEnvScript strategy="afterInteractive" />
</head>
For more information about the issue, check out: https://github.com/vercel/next.js/issues/69567#issuecomment-2334542530 Forked version: https://github.com/expatfile/next-runtime-env/pull/150
Issue
When a page defaults to the not-found page client components fail to load the environment variables (all NEXT_PUBLIC) are undefined while on the server they have the correct values.
This is happening in all 3.X versions I tried and with Nextjs app router v14