-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Revert vercel env fix #6776
Revert vercel env fix #6776
Conversation
🦋 Changeset detectedLatest commit: 58d392d The changes in this PR will be included in the next version bump. 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 |
Ah right I forgot that private env vars are only replaced when transforming files in SSR, which the analytics script is client only. As a fix, the Vercel adapter could update the Vite config to add |
@bluwy that's a fix for the initial problem, right? I'm going to assume that we need to merge this first. |
The |
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.
Let's merge this for now then, and we can revisit this again.
Maybe we could simply make the variable public by passing it to the client side. As a workaround/POC, this works by editing the
So maybe it would also be achievable directly in the adapter? Otherwise, maybe the "define" could also work for this case. The Vite documentation states:
define: {
'import.meta.env.ENV_VARIABLE': JSON.stringify(process.env.ENV_VARIABLE)
} This is simply food for though, as I assume adding a |
The docs doesn't mention |
I can confirm vite-define works for this case. In astro.config: vite: {
define: {
'import.meta.env.PUBLIC_VERCEL_ANALYTICS_ID': JSON.stringify(
process.env.VERCEL_ANALYTICS_ID
),
},
}, |
Apologies, in my efforts to find out why the key wasn't being included, allowed myself to lose track of the fact that only environment variables that are prefixed with PUBLIC_ will be bundled at build time.
Changes
Testing
Didn't have the desired effect, this simply reverts it back to how it was.
Docs
/cc @withastro/maintainers-docs for feedback!