drawdb-io / drawdb-io/drawdb

[BUG] Cannot change backend URL when using docker image

Open
#1,025 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
39.5k
Forks
3.2k
Avg merge
10h 46m
Merged PRs (30d)
16

Description

**Describe the bug**
The `VITE_BACKEND_URL` environment variable is evaluated at compile time, meaning it cannot be set unless the docker image is manually built in an environment with the environment set.

**To Reproduce**
1. Run `docker run --rm -p 3024:80 -e VITE_BACKEND_URL=https://example.com --name drawdb-test ghcr.io/drawdb-io/drawdb:latest`
2. Navigate to `http://localhost:3024/editor/`
3. Open browser dev-tools
4. Click on Share
5. Notice that it tries to make a POST request to `http://localhost:3024/editor/diagrams/undefined/gists` (undefined because VITE_BACKEND_URL resolved to undefined during build-time)

**Expected behavior**
VITE_BACKEND_URL should be correctly evaluated (in this case `https://example.com`) instead of being evaluated as `undefined` or as whatever value existed for it during compile-time

**Desktop (please complete the following information):**
- OS: GNU/Linux
- Browser Floorp 12.14.2@151.0

**Additional context**
`import.meta.env.VITE_BACKEND_URL` is evaluated at build-time.
https://vite.dev/guide/env-and-mode#node-env-and-modes

Contributor guide

Open the contributing guide

Research direction

Start by tracing where import.meta.env.VITE_BACKEND_URL is consumed and how the Docker image starts in the deployed container. Reproduce the issue with the provided docker run command, then verify that the Share request uses the runtime-supplied https://example.com URL rather than a compile-time or undefined value.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, javascript, vite
Domain
devops, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.