For browser-side import.meta.env values in a Vite static build, change the build environment and produce a new bundle. Compare the deployed asset and actual request before investigating caches.
If a deployed Vite site still uses an old API address, set the variable where the build runs, then build and deploy fresh output. Browser-side values read through import.meta.env are substituted during a Vite production build.
Changing a runtime setting on a static host cannot rewrite JavaScript that has already been built.
I start with the JavaScript the browser loaded and the API request it made. If the browser received the new bundle and still calls staging, check which value the build inherited.
Confirm where your code reads the value
Look at the call site. import.meta.env.VITE_API_BASE in browser code is a public build input. A setting read by server code at runtime has a different lifecycle.
In an app that has both a browser bundle and server functions, find the code that creates the failing request before changing either set of variables.
With Vite’s default settings, browser code can read variables that begin with VITE_. Treat those values as public and keep service credentials on the server.

Source: Vite’s Env Variables and Modes guide. The opening paragraph explains when a value becomes part of the build.
I changed the file and inspected two builds
On November 13, in a local Vite 8.3.3 fixture, I set VITE_API_BASE in .env.production to a synthetic staging hostname and ran a production build. The generated JavaScript contained the staging hostname.
I changed the file to a synthetic production hostname and inspected the existing output again. It still had the staging hostname and the same entry filename.
I ran a new build to a separate directory. The new entry contained the production hostname and no longer contained the staging value.

Local Vite production build · synthetic hosts. Observed November 13, 2026.
I inspected the generated files locally. The API addresses were synthetic. Checking a real browser request is the deployment step below.
When a fresh build still uses staging, check the build job
On November 30, I built a second Vite 8.3.3 fixture twice. I kept .env.production set to https://production.example.invalid in both builds. For the first build, I also supplied VITE_API_BASE=https://staging.example.invalid to the build process. Its JavaScript contained only the staging address.
When I removed the process variable and rebuilt, the emitted JavaScript contained only the production address. A value already set in the build job wins over the value in the mode file. Check the specific variable in the job that produced your deployment.
Follow the path from the setting to the request
- Find the deployment’s build log. Confirm the commit, environment and command that produced the artifact. A job that uploads an existing directory skips Vite entirely.
- Read the build command.
vite builduses production mode by default. Withvite build --mode staging, Vite reads.env.stagingeven whenNODE_ENVisproduction. - Inspect the new output before deploying. Start at the built
index.htmland search the emitted JavaScript for the expected public hostname. A route can load its API code from a separate chunk. - Deploy that output. Open the affected page with the browser’s Network panel open and repeat the action. Check the request URL and its initiator, then match the JavaScript asset to your build.
If the public HTML still references an old asset, confirm that the new HTML reached the host. Then check the response headers and any service worker that serves the page. Vite’s production build guide recommends Cache-Control: no-cache on HTML so the browser revalidates it.
If the browser has the new asset and still contacts the wrong host, trace the code that made the request. It could use a different variable or a server endpoint. Fix the request source you observed.
Pick a configuration model for the next change
If the API address changes only when you release, a build-time value is easy to trace. Record the build mode, the public host and the deployment ID together.
If an operator needs to change the address between releases, the app can fetch a same-origin public configuration document at startup.
Plan what it does when that document is missing, out of date or points to an invalid host. Keep secrets and authorization on the server.
Start with one request in the browser. The fix passes when the served HTML references the intended new build and that request reaches the correct host. If you are inheriting a project from a builder, add the variable names and who configures them to your code-export inventory.
Sources & scope
Capabilities are based on these official sources. Recommendations are editorial judgments. Hands-on scope: Local Vite 8.3.3 production builds using synthetic API hostnames. We inspected the emitted JavaScript after a file edit and after changing an environment variable supplied to the build process.
- Vite environment variables and modes ↗Checked Nov 30, 2026
- Vite production builds ↗Checked Nov 30, 2026