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

How to using Vite Env Variables? #3896

Closed
4 tasks done
QC2168 opened this issue May 17, 2024 · 2 comments
Closed
4 tasks done

How to using Vite Env Variables? #3896

QC2168 opened this issue May 17, 2024 · 2 comments
Labels
need more info Further information is requested

Comments

@QC2168
Copy link

QC2168 commented May 17, 2024

Describe the bug

My project add network request, But I need different environment variables control the request address, how should I use env in vite

Env Variables

Reproduction

None

Expected behavior

I want to be able to access import.meta.env.BASE_URL, just like the vite project

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-12600KF
    Memory: 2.31 GB / 31.82 GB
  Binaries:
    Node: 18.19.0 - D:\software\nodejs\node.EXE
    npm: 10.2.3 - D:\software\nodejs\npm.CMD
    pnpm: 9.1.1 - ~\AppData\Local\pnpm\pnpm.CMD
    bun: 1.1.3 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (123.0.2420.97)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    vitepress: 1.0.2 => 1.0.2

Additional context

No response

Validations

@QC2168 QC2168 added the bug: pending triage Maybe a bug, waiting for confirmation label May 17, 2024
@brc-dd
Copy link
Member

brc-dd commented May 17, 2024

import.meta.env.BASE_URL should work fine in client. Please share minimal reproducible example using https://vitepress.new

@brc-dd brc-dd added need more info Further information is requested and removed bug: pending triage Maybe a bug, waiting for confirmation labels May 17, 2024
@QC2168
Copy link
Author

QC2168 commented May 17, 2024

I solved it! I should put the env file to docs folder

@QC2168 QC2168 closed this as completed May 17, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need more info Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants