Skip to content

Local env variables are loaded with inlined comments #59562

Closed as not planned
Closed as not planned
@OGReabon

Description

@OGReabon

Link to the code that reproduces this issue

Link

To Reproduce

  1. In .env file define NEXT_PUBLIC_SOMETHING variable and add comment after it as #some comment that should not be loaded
  2. Use the NEXT_PUBLIC_SOMETHING variable somewhere and log it.
  3. Start the application and see that both the value and the comment are printed in the log.

Current vs. Expected behavior

Currently the dotenv loader loads everything after the = sign.
Expected behaviour would be that the loader only loads the value and not the comment.

Verify canary release

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

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:34 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T8103
    Binaries:
      Node: 21.1.0
      npm: 10.2.0
      Yarn: 1.22.19
      pnpm: N/A
    Relevant Packages:
      next: 13.4.9
      eslint-config-next: 13.4.9
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.staleThe issue has not seen recent activity.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions