question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inject environment variables

See original GitHub issue

Use case: I have NEXT_PUBLIC_DEPLOYMENT_URL. In order to read it I have to use manually dotenv, which is not ideal.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
reubncommented, Dec 2, 2020

While I’d agree that injecting environment variables wouldn’t be in scope for a standalone sitemap generator, I don’t agree that it shouldn’t be in scope for this project: given its tight coupling with Next.js.

Next.js injects environment variables. If this was a normal Next.js plugin (i.e. one that made use of webpack / the next.config.js file) then the variables would be injected. It’s only due to the mechanism behind this plugin that they aren’t - but to ensure a consistent DX, surely it would be preferable that they are.

It’s a 2 line fix with no dependencies other than Next.js itself:

const env = require('@next/env')

env.loadEnvConfig(process.cwd(), process.env.NODE_ENV === 'development')
1reaction
iamvishnusankarcommented, Mar 18, 2021

@reubn I totally missed this since you commented on a closed issue. I have added support for .env loading. Consider mentioning my username or reopen the issue next time.

@ilgarm It’s here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment Injector - Jenkins Plugins
Removes inherited environment variables by the Jenkins Java process · Injects environment variables at node (controller/agent) startup · Executes ...
Read more >
How to set environment variables in Jenkins? - Stack Overflow
Go to your job Configure screen · Find Add build step in Build section and select Inject environment variables · Set the desired...
Read more >
Inject environment variables with the CircleCI API
You can inject environment variables with the build_parameters key to enable your functional tests to build against different targets on each run (for ......
Read more >
How to Use Environment Variables the Right Way
Instead of using environment variables (dependencies) directly, we inject them at callsites (that is, the place they are actually used).
Read more >
Jenkins Environment Variables: Ultimate Guide - phoenixNAP
Adding the EnvInject plugin to Jenkins allows you to inject environment variables during the build startup. This is particularly useful when ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found