-
Notifications
You must be signed in to change notification settings - Fork 440
Description
Preliminary Checks
-
I have reviewed the documentation: https://clerk.com/docs
-
I have searched for existing issues: https://github.com/clerk/javascript/issues
-
I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
-
This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.
Reproduction
zipped repo attached below
Publishable key
pk_test_Zm9uZC1tYW50aXMtNTIuY2xlcmsuYWNjb3VudHMuZGV2JA
Description
I think this is basically a nextjs version of this issue fro the remix connector.
Steps to reproduce:
- unzip this repo (which I scaffolded from
npm create cloudflare@latest -- my-next-app --framework=nextper cloudflare's guide, and then followed clerk's nextjs instructions) - add the needed secret key, which I obfuscated.
- run
npm run previewwhich builds the nextjs app and then does some cloudflare magic to make the middleware functions run on cloudflare workers [if I understand correctly...] - open the localhost link.
Expected behavior:
Clerk will find the env vars I set in .env, and the login widget etc will work.
Actual behavior:
I get a 500 error because the secret key is not found. Clerk only looks within process.env for the needed env vars. But I am deploying to cloudflare workers, in which process.env is empty. To get this to work correctly, I instead of putting the env vars in .env, I need to put them in .dev.vars, which is cloudflare's version of this.
I think the solution is the same as in the linked issue above, where clerk looks through context.cloudflare.env instead. To really make this robust, if possible, really I think this logic for fetching env vars should get hoisted to some common util package where all the different framework connectors can use it, and so it will be solved for all of them.
Environment
System:
OS: macOS 14.6.1
CPU: (10) arm64 Apple M1 Max
Memory: 10.16 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 23.5.0 - /opt/homebrew/bin/node
npm: 10.9.2 - /opt/homebrew/bin/npm
pnpm: 9.15.1 - /opt/homebrew/bin/pnpm
Browsers:
Chrome: 131.0.6778.265
Safari: 17.6