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

fix(nextjs): do not warn on NX_INVOKED_BY_RUNNER and only show warning once #19254

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

jaysoo
Copy link
Member

@jaysoo jaysoo commented Sep 20, 2023

We added a deprecation warning for environment variables prefixed with NX_ (that are not set by Nx or Nx Cloud). Since Next.js apps run both in server and browser, any environment variables should only be used by the server (in RSC or API route), to prevent security leaks.

However, our warnings did not exclude NX_INVOKED_BY_RUNNER, which is set by the Nx Cloud runner. This is causing user confusion. We are also warning too many times, since Next.js build/serve can load webpack config up to three times (browser, server, edge).

This PR makes the warning go away unless user explicitly sets a custom NX_ variable, thinking that it will be available for use in the browser. When the warning does show up, it will only show once.

Current Behavior

Expected Behavior

Related Issue(s)

Fixes #

@jaysoo jaysoo requested a review from a team as a code owner September 20, 2023 14:31
@jaysoo jaysoo requested a review from mandarini September 20, 2023 14:31
@vercel
Copy link

vercel bot commented Sep 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Sep 20, 2023 2:31pm

@jaysoo jaysoo merged commit 9362de0 into nrwl:master Sep 20, 2023
3 checks passed
@jaysoo jaysoo deleted the fix/nextjs-env-var-warnings branch September 20, 2023 15:30
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants