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

Multiline environment variables dont work as expected #53183

Closed
1 task done
nuntax opened this issue Jul 25, 2023 · 3 comments
Closed
1 task done

Multiline environment variables dont work as expected #53183

nuntax opened this issue Jul 25, 2023 · 3 comments
Labels
bug Issue was opened via the bug report template. locked

Comments

@nuntax
Copy link

nuntax commented Jul 25, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Pro
    Binaries:
      Node: 18.17.0
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant Packages:
      next: 13.4.13-canary.2
      eslint-config-next: 13.4.12
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

https://github.com/nuntax/next-js-bugreport

To Reproduce

Have a multiline environment variable like a ecdsa key for JWT usage.
.env.local:

PUBLIC_KEY='-----BEGIN PUBLIC KEY-----
multi-line
-----END PUBLIC KEY-----'

When now logging the environment variable:
console.log(process.env.PUBLIC_KEY)
The console output looks like the following:
'-----BEGIN PUBLIC KEY-----

Describe the Bug

Only the first line of the environment variable is getting loaded.
Weirdly enough adding the experimental --turbo flag to next dev resolves the issue.

Expected Behavior

The expected behaviour is that the entire variable is loaded and that
console.log(process.env.PUBLIC_KEY)
prints

PUBLIC_KEY='-----BEGIN PUBLIC KEY-----
multi-line
-----END PUBLIC KEY-----'

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@nuntax nuntax added the bug Issue was opened via the bug report template. label Jul 25, 2023
@balazsorban44
Copy link
Member

This is currently not possible, as it would be a breaking change to update dotenv.

You can follow this PR: #38481 (comment)

@nuntax
Copy link
Author

nuntax commented Jul 26, 2023

For anyone looking for a workaround, just replace the line breaks with \n.

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2023
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. locked
Projects
None yet
Development

No branches or pull requests

2 participants