Bug Description
Several frontend services read VITE_BASE_URL directly with no fallback value, while most other files in the codebase guard it with || 'http://localhost:1313'. When VITE_BASE_URL is not set (e.g. a new contributor clones the repo and forgets to create frontend/.env), baseURL becomes undefined, so every request is sent to undefined/<path> and fails silently.
Affected files (no fallback):
src/services/profileService.ts
src/services/vsbot.ts
src/services/adminService.ts
src/services/leaderboardService.ts
// e.g. profileService.ts
const baseURL = import.meta.env.VITE_BASE_URL; // undefined if not set
// → fetch(`${baseURL}/user/fetchprofile`) hits "undefined/user/fetchprofile"
For contrast, other files handle this correctly:
const baseURL = import.meta.env.VITE_BASE_URL || 'http://localhost:1313';
// e.g. transcriptService.ts, gamificationService.ts, CommentTree.tsx, etc.
This is a separate issue from #434 — that one is about the wrong variable name (VITE_API_URL never being defined). This is about the correct variable (VITE_BASE_URL) being read without a fallback, causing an inconsistent developer experience and a confusing, hard-to-trace "Failed to fetch" for anyone who hasn't set the env var.
Steps to Reproduce
- Clone the repo and do NOT create a
frontend/.env file (or leave VITE_BASE_URL unset).
- Run the frontend dev server.
- Navigate to a page that uses one of the affected services (e.g. Profile, Leaderboard).
- Observe the request goes to
undefined/... and fails with "Failed to fetch"; no clear indication that the env var is the cause.
Logs and Screenshots
$ grep -rn "VITE_BASE_URL;" frontend/src/services/
frontend/src/services/profileService.ts:1:const baseURL = import.meta.env.VITE_BASE_URL;
frontend/src/services/vsbot.ts:3:const baseURL = import.meta.env.VITE_BASE_URL;
frontend/src/services/adminService.ts:1:const baseURL = import.meta.env.VITE_BASE_URL;
frontend/src/services/leaderboardService.ts:1:const baseURL = import.meta.env.VITE_BASE_URL;
Environment Details
Impact
Low - Minor inconvenience
Code of Conduct
Bug Description
Several frontend services read
VITE_BASE_URLdirectly with no fallback value, while most other files in the codebase guard it with|| 'http://localhost:1313'. WhenVITE_BASE_URLis not set (e.g. a new contributor clones the repo and forgets to createfrontend/.env),baseURLbecomesundefined, so every request is sent toundefined/<path>and fails silently.Affected files (no fallback):
src/services/profileService.tssrc/services/vsbot.tssrc/services/adminService.tssrc/services/leaderboardService.tsFor contrast, other files handle this correctly:
This is a separate issue from #434 — that one is about the wrong variable name (
VITE_API_URLnever being defined). This is about the correct variable (VITE_BASE_URL) being read without a fallback, causing an inconsistent developer experience and a confusing, hard-to-trace "Failed to fetch" for anyone who hasn't set the env var.Steps to Reproduce
frontend/.envfile (or leaveVITE_BASE_URLunset).undefined/...and fails with "Failed to fetch"; no clear indication that the env var is the cause.Logs and Screenshots
$ grep -rn "VITE_BASE_URL;" frontend/src/services/
frontend/src/services/profileService.ts:1:const baseURL = import.meta.env.VITE_BASE_URL;
frontend/src/services/vsbot.ts:3:const baseURL = import.meta.env.VITE_BASE_URL;
frontend/src/services/adminService.ts:1:const baseURL = import.meta.env.VITE_BASE_URL;
frontend/src/services/leaderboardService.ts:1:const baseURL = import.meta.env.VITE_BASE_URL;
Environment Details
Impact
Low - Minor inconvenience
Code of Conduct