Skip to content
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

fix(tanstack-start): Fix ENV variable loading #4743

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

octoper
Copy link
Member

@octoper octoper commented Dec 10, 2024

Description

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Copy link

changeset-bot bot commented Dec 10, 2024

⚠️ No Changeset found

Latest commit: f3a0440

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Dec 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ⬜️ Skipped (Inspect) Dec 10, 2024 0:10am

@octoper
Copy link
Member Author

octoper commented Dec 10, 2024

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @octoper - the snapshot version command generated the following package versions:

Package Version
@clerk/astro 2.0.1-snapshot.v20241210001110
@clerk/backend 1.20.3-snapshot.v20241210001110
@clerk/chrome-extension 2.0.9-snapshot.v20241210001110
@clerk/clerk-js 5.40.3-snapshot.v20241210001110
@clerk/elements 0.21.4-snapshot.v20241210001110
@clerk/clerk-expo 2.4.5-snapshot.v20241210001110
@clerk/expo-passkeys 0.0.17-snapshot.v20241210001110
@clerk/express 1.3.26-snapshot.v20241210001110
@clerk/fastify 2.0.28-snapshot.v20241210001110
@clerk/localizations 3.8.2-snapshot.v20241210001110
@clerk/nextjs 6.8.3-snapshot.v20241210001110
@clerk/nuxt 0.0.13-snapshot.v20241210001110
@clerk/clerk-react 5.19.3-snapshot.v20241210001110
@clerk/react-router 0.0.2-snapshot.v20241210001110
@clerk/remix 4.3.6-snapshot.v20241210001110
@clerk/clerk-sdk-node 5.0.77-snapshot.v20241210001110
@clerk/shared 2.19.4-snapshot.v20241210001110
@clerk/tanstack-start 0.7.0-snapshot.v20241210001110
@clerk/testing 1.3.38-snapshot.v20241210001110
@clerk/themes 2.1.55-snapshot.v20241210001110
@clerk/types 4.39.2-snapshot.v20241210001110
@clerk/ui 0.2.4-snapshot.v20241210001110
@clerk/vue 0.0.17-snapshot.v20241210001110

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/elements

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/expo-passkeys

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

@clerk/localizations

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/nuxt

npm i @clerk/[email protected] --save-exact

@clerk/clerk-react

npm i @clerk/[email protected] --save-exact

@clerk/react-router

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/clerk-sdk-node

npm i @clerk/[email protected] --save-exact

@clerk/shared

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@clerk/themes

npm i @clerk/[email protected] --save-exact

@clerk/types

npm i @clerk/[email protected] --save-exact

@clerk/ui

npm i @clerk/[email protected] --save-exact

@clerk/vue

npm i @clerk/[email protected] --save-exact

@wobsoriano
Copy link
Member

wobsoriano commented Dec 12, 2024

Might be a good PR to add this fix. We have a report here that deployment to CF pages and local dev via wrangler is not working due to environment variables not being loaded.

process.env and import.meta.env objects are empty in CF pages, but nitro/h3 injects the CF variables to the event.context.cloudflare object and we can access them using getContext(). I think we can add another condition to the getEnvVariable helper:

import { getContext } from 'vinxi/http'

export const getEnvVariable = (name: string, defaultVaue: string = ''): string => {
  // existing code
  
  if (getContext('cloudflare')) {
    return getContext('cloudflare').env[name];
  }

  return defaultVaue;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants