env vars declared in .env[.(development|production)]
are undefined at runtime.
#62230
Labels
bug
Issue was opened via the bug report template.
invalid link
The issue was auto-closed due to a missing/invalid reproduction link. A new issue should be opened.
Pages Router
Related to Pages Router.
Link to the code that reproduces this issue
npx create-next-app
To Reproduce
Inside of a fetch function call in
next.jsv14
pass in a URL populated as an environment variable.Current vs. Expected behavior
During runtime - this throws the following error:
It seems as though the environment variable is undefined at runtime. This issue does not occur when I replace
process.env.API_ENDPOINT
with the hard-coded string of API endpoint.Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000 Binaries: Node: 20.11.1 npm: 10.2.4 Yarn: 1.22.21 pnpm: 8.15.3 Relevant Packages: next: 14.1.0 eslint-config-next: 14.1.0 react: 18.2.0 react-dom: 18.2.0 typescript: 5.3.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Data fetching (gS(S)P, getInitialProps)
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response
The text was updated successfully, but these errors were encountered: