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

Warning when using a custom Next.js server #19492

Closed
1 of 4 tasks
jasongerbes opened this issue Oct 8, 2023 · 2 comments · Fixed by #19585
Closed
1 of 4 tasks

Warning when using a custom Next.js server #19492

jasongerbes opened this issue Oct 8, 2023 · 2 comments · Fixed by #19585
Assignees
Labels
outdated scope: nextjs Issues related to NextJS support for Nx type: bug

Comments

@jasongerbes
Copy link
Contributor

Current Behavior

When using a custom Next.js, using the default custom server template, the following warning is logged in the console output:

Warning, in Nx 18 environment variables starting with NX_ will not be available in the browser, and currently will not work with @nx/next:server executor.
Please rename the following environment variables: NX_NEXT_PUBLIC_DIR, NX_FILE_TO_RUN, NX_MAPPINGS using Next.js' built-in support for environment variables. Reference https://nextjs.org/docs/pages/api-reference/next-config-js/env

This appears to be due to this line in the generated server/main.ts file:

const dir = process.env.NX_NEXT_DIR || path.join(__dirname, '..');

Expected Behavior

There shouldn't be any warnings when serving a Next.js application with a custom server.

GitHub Repo

No response

Steps to Reproduce

  1. Create a new Nx workspace
  2. Add a Next.js application via nx g @nx/next:application
  3. Add a custom server via nx g @nx/next:custom-server
  4. Serve your Next.js app via nx serve [app-name]

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 16.18.0
   OS     : darwin-arm64
   npm    : 8.19.2
   
   nx                 : 16.10.0
   @nx/js             : 16.10.0
   @nx/jest           : 16.10.0
   @nx/linter         : 16.10.0
   @nx/workspace      : 16.10.0
   @nx/cypress        : 16.10.0
   @nx/devkit         : 16.10.0
   @nx/eslint-plugin  : 16.10.0
   @nx/next           : 16.10.0
   @nx/plugin         : 16.10.0
   @nx/react          : 16.10.0
   @nx/storybook      : 16.10.0
   @nrwl/tao          : 16.10.0
   @nx/web            : 16.10.0
   @nx/webpack        : 16.10.0
   nx-cloud           : 16.4.0
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   nx-stylelint : 15.0.0
   ---------------------------------------
   Local workspace plugins:
         @vista-digital/nx-plugin

Failure Logs

Warning, in Nx 18 environment variables starting with NX_ will not be available in the browser, and currently will not work with @nx/next:server executor.
Please rename the following environment variables: NX_NEXT_PUBLIC_DIR, NX_FILE_TO_RUN, NX_MAPPINGS using Next.js' built-in support for environment variables. Reference https://nextjs.org/docs/pages/api-reference/next-config-js/env

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@jdpnielsen
Copy link

I'm warnings about the following variables in my setup: NX_BATCH_MODE, NX_INVOKED_BY_RUNNER.
Would it make sense to add an interface for users to add variables which should be ignored?

Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: nextjs Issues related to NextJS support for Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants