Unable to use @clerk/tanstack-start
w/ Cloudflare deployment or local development
#4632
Open
4 tasks done
Labels
needs-triage
A ticket that needs to be triaged by a team member
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
https://github.com/pdlug/tanstack-start-clerk
Publishable key
pk_test_bWFzc2l2ZS10ZXJtaXRlLTY1LmNsZXJrLmFjY291bnRzLmRldiQ
Description
I'm using Tanstack Start with the
@clerk/tanstack-start
package and trying to get it to work when deploying to Cloudflare. It works great running locally with the vinxi dev server but I cannot get it to pick up the publishable and secret keys when running locally with Cloudflare'swrangler
CLI or in an actual deployment even though I have them set.Steps to reproduce:
See this minimal repo that reproduces the issue: https://github.com/pdlug/tanstack-start-clerk
@clerk/tanstack-start
with config updates specified in the docswrangler pages dev
to preview the app locally. Loading the app you'll get a 500 error with@clerk/tanstack-start: Clerk: no secret key provided
in the console.I've added the
CLERK_PUBLISHABLE_KEY
andCLERK_SECRET_KEY
to.dev.vars
which is whatwrangler
uses to set environment variables running locally but that didn't work. I also set them as environment variables (secrets) in a Cloudflare deployment and deployed. I get the same error when running live in Cloudflare as I do locally.It looks like I can pass the publishable and secret keys to
createClerkHandler
but I haven't figured out how to actually get those from the environment. Cloudflare exposes them on the context which is called when the handler runs so I'm thinking the issue may be that the code in@clerk/tanstack-start
seems to rely on it being inimport.meta.env
at the time it's loaded.Tanstack Start uses Vinxi with Nitro to abstract the webserver. My knowledge of both is rather limited.
Expected behavior:
Expected
@clerk/tanstack-start
to pick up the configured environment variables running in a Cloudflare deployment.Actual behavior:
500 error with the console message:
Environment
The text was updated successfully, but these errors were encountered: