Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env variables from .env* file don't expose to next.config.* anymore #22881

Closed
fliptheweb opened this issue Mar 8, 2021 · 3 comments
Closed
Labels
bug Issue was opened via the bug report template.

Comments

@fliptheweb
Copy link
Contributor

fliptheweb commented Mar 8, 2021

What version of Next.js are you using?

10.0.8

What version of Node.js are you using?

14.7.0

What browser are you using?

any

What operating system are you using?

macOS

How are you deploying your application?

local, codesandbox

Describe the Bug

Env variables don't expose to next.config.js and not available w/o manual using dotenv package.
Seems like after '10.0.8' nextjs starts to use next-env after next.config loaded.

Expected Behavior

We should be able to use Env variables in next.config, webpack, plugins configurations.

To Reproduce

Sandbox with 10.0.8 and the behavior:
https://codesandbox.io/s/nextjs-1008-process-env-bug-wmwkn
in terminal

check VAR env: undefined
check NEXT_PUBLIC_VAR env: undefined
warn  - Detected next.config.js, no exported configuration found.https://err.sh/vercel/next.js/empty-configuration
info  - Loaded env from /sandbox/.env

Sandbox with 10.0.7 w/o:
https://codesandbox.io/s/nextjs-1007-process-env-nvnnh
in terminal

Loaded env from /sandbox/.env
check VAR env: FOO
check NEXT_PUBLIC_VAR env: BAR
@fliptheweb fliptheweb added the bug Issue was opened via the bug report template. label Mar 8, 2021
@fliptheweb fliptheweb changed the title Env variables from .env* file doesn't expose to next.config.* anymore Env variables from .env* file don't expose to next.config.* anymore Mar 8, 2021
@matamatanot
Copy link
Contributor

Check #22879.
You can try out https://github.com/vercel/next.js/releases/tag/v10.0.9-canary.2 .

@ijjk
Copy link
Member

ijjk commented Mar 8, 2021

Closing as a duplicate of #22811 per above

@ijjk ijjk closed this as completed Mar 8, 2021
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

4 participants