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.

[Feature Request] Set os environment variable during dev

See original GitHub issue

When running miniflare from cli (or perhaps through node api) set a process.env.MINIFLARE = true header.

Why?

When using build tools like esbuild or like id like to run slightly different code during my local dev time, than the worker running on the real platform.

Currently im env MINIFLARE=1 miniflare — but be awesome to have this first-class.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
mrbbotcommented, Oct 16, 2021

Hey! 👋 This definitely sounds useful for build scripts. Wondering if it’s also worth setting a MINIFLARE global to true in the actual worker context too… 🤔

1reaction
mrbbotcommented, Nov 25, 2021

Hey! 👋 Depends on where you’re using it. If it’s in your actual worker code…

if (globalThis.MINIFLARE) {
  // Do something when running in Miniflare
} else {
  // Do something when running in production
}

Note the globalThis. to avoid the ReferenceError.

If it’s in a custom Node.js build script, say build.js

if(process.env.MINIFLARE) {
  // Do something when building for Miniflare
} else {
  // Do something when building for production
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment Variables: What They Are and How To Use Them
Environment variables add dynamicity to your static code base; you can switch between internal/external resources based on the value of the ...
Read more >
Use multiple environments in ASP.NET Core | Microsoft Learn
Use multiple environments in ASP.NET Core · Environments · Set the environment by setting an environment variable · Set the environment in code....
Read more >
Set an Environment Variable - Forum - VisualCron
Is there a way to set the value of an environment variable for all the tasks in a job? Ideally the list of...
Read more >
Basic Features: Environment Variables - Next.js
Environment Variables on Vercel​​ When deploying your Next.js application to Vercel, Environment Variables can be configured in the Project Settings. All types ...
Read more >
Environment Variables – Vercel Docs
The Add New section of the Environment Variables page in the Project Settings. Enter the desired Name for your Environment Variable. For example,...
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