-
Notifications
You must be signed in to change notification settings - Fork 299
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
does not find env vars when deployed to cloudflare using nextjs connector #4877
Comments
I am also experiencing this with the nuxt module running on cloudflare pages, in praticular since migrating form vue-clerk to the new official @clerk/nuxt module. |
The same thing seems to be happening with
I'm having issues on this stack deploying to cf pages specifically. |
We fixed reading of CF env vars in @clerk/tanstack-start #4743. The example you mentioned is using an outdated version of |
Hi, @jontybrook I believe it should work as Nuxt/Nitro has a way of handling runtime variables. I have a demo app deployed to CF pages via NuxtHub here that uses |
Hi @NickCrews, thank you for reporting this! I unzipped your repo and can confirm that for local development with wrangler, you're on the right track using Upon investigation, I found that Cloudflare's next-on-pages tool doesn't currently inject environment variables into the runtime context like other frameworks' adapters do (such as Nuxt, Remix, React Router, or TanStack Start). In those frameworks, we're able to read from Some examples on how other frameworks has access to context: We understand this might not be the most convenient setup, and we'll monitor any improvements in the next-on-pages adapter. |
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:
npm create cloudflare@latest -- my-next-app --framework=next
per cloudflare's guide, and then followed clerk's nextjs instructions)npm run preview
which builds the nextjs app and then does some cloudflare magic to make the middleware functions run on cloudflare workers [if I understand correctly...]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
The text was updated successfully, but these errors were encountered: