Skip to content

fix import meta env reference in env docs#5222

Merged
sarah11918 merged 2 commits into
mainfrom
fix-import-meta-env
Oct 31, 2023
Merged

fix import meta env reference in env docs#5222
sarah11918 merged 2 commits into
mainfrom
fix-import-meta-env

Conversation

@FredKSchott
Copy link
Copy Markdown
Member

Description (required)

I ended up findings some Vite docs on how to fix this, and ended up trying a few things before realizing that this worked in dev (and assuming preview/prod as well).

Before: Because Vite statically replaces import\u002Emeta.env, you cannot access it with dynamic keys like import\u002Emeta.env[key].

After: Because Vite statically replaces import.meta.env, you cannot access it with dynamic keys like import.meta.env[key].

@netlify
Copy link
Copy Markdown

netlify Bot commented Oct 28, 2023

Deploy Preview for astro-docs-2 ready!

Name Link
🔨 Latest commit 65e6ca7
🔍 Latest deploy log https://app.netlify.com/sites/astro-docs-2/deploys/65417a51b81ef2000878e27e
😎 Deploy Preview https://deploy-preview-5222--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Copy Markdown
Member

@at-the-vr at-the-vr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds accurate. unless VITE_ is used as a prefix, env variables are not accessible in client side link to production replacement by Vite

Copy link
Copy Markdown
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works!

@sarah11918 sarah11918 merged commit 3e1c2fe into main Oct 31, 2023
@sarah11918 sarah11918 deleted the fix-import-meta-env branch October 31, 2023 22:14
yanthomasdev added a commit that referenced this pull request Nov 11, 2023
Update minor translation #5222

Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants