Skip to content

Access environment variables in custom server #12269

@NewBieBR

Description

@NewBieBR

Feature request

Is your feature request related to a problem? Please describe.

Environment variables are undefined in a custom server. For example in server.js

...
const app = next({dev});
console.log(process.env.MY_ENV_VARIABLE);
...

In next.config.js:

module.exports = {
  env: {
     MY_ENV_VARIABLE: 'hello',
  },
};

Output:

undefined

Describe the solution you'd like

I would like to be able to use environment variable in a custom server.

Describe alternatives you've considered

No

Additional context

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions