0

I have a React application built using Vite. For local development, I have set up an .env file which contains a VITE_URL variable.

Here is a brief overview of my setup:

Build Tool: Vite Source Control: GitLab (used to generate a container image for the app) Hosting: Azure Web Apps (containerized deployment) Requirement: I need the VITE_URL variable to change based on the environment (e.g., development, staging, production).

Current Setup:

In Azure Web Apps, I have set up an application setting named VITE_URL, but this value is not being passed into the container. Problem: When deploying the application to different environments, the VITE_URL does not update according to the Azure Web Apps configuration.

What Works:

The only solution that works so far is adding a .env.production file with the URL. However, this does not satisfy the requirement because I need to have different URLs based on the deployed environment. Question: How can I configure my Azure Web Apps container to pass different VITE_URL values based on the environment?

What I have tried:

Setting VITE_URL as an environment variable in Azure Web Apps. Confirmed the variable is set in Azure Web Apps configuration settings. Rebuilding and redeploying the container after setting the environment variable.

1 Answer 1

0

I found another post that led me in the right direction.
See Change Environmet Variables at runtime (React, vite) with docker and nginx

Post by Anas sain.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.