-
Notifications
You must be signed in to change notification settings - Fork 295
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
feat(shared): Support passing env source into runtime environment helpers [SDK-773] #1881
Conversation
🦋 Changeset detectedLatest commit: 3f73e9f The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…pers We can support cases like per-request env in Cloudflare workers
a2149aa
to
3f73e9f
Compare
// TODO: add support for import.meta.env.DEV that is being used by vite | ||
return false; | ||
const getRuntimeFromProcess = (env?: typeof process.env) => { | ||
return env?.NODE_ENV; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ @dimkl this one applies only on node environments, right?
Or, if you pass an env
object, it should include a NODE_ENV
property for this to work, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it applies for all runtimes (Node, Cloudflare Workers, ...).
If you pass an env
object with the NODE_ENV
property, it should work.
I probably need to test if the process.env
type works for Vite and Cloudflare workers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dimkl That's what I meant. You need to have NODE_ENV
in your passed object for this to work. NODE_ENV
usually refers to node environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this name is a bit misleading. At the moment the function assumes that NODE_ENV
exists and that it's Node.js
You can do a check for the runtime like this: https://github.com/unjs/std-env/blob/main/src/runtimes.ts
Probably the whole "runtime" name (also for the file name) is a bit misleading as we only check the NODE_ENV
environment 🤔
This PR has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
Changes:
Currently we cannot support per-request environment variables for helpers using the runtimeEnvironment helpers since we should pass the
env
parameter fromfetch()
handler down to all functions using it. An alternative way to support this is to manually copy these values intoprocess.env
(see Cloudflare ref).Checklist
npm test
runs as expected.npm run build
runs as expected.Type of change
Packages affected
@clerk/clerk-js
@clerk/clerk-react
@clerk/nextjs
@clerk/remix
@clerk/types
@clerk/themes
@clerk/localizations
@clerk/clerk-expo
@clerk/backend
@clerk/clerk-sdk-node
@clerk/shared
@clerk/fastify
@clerk/chrome-extension
gatsby-plugin-clerk
build/tooling/chore