Skip to content

Commit 6cdf0f0

Browse files
rlafurudclaude
andcommitted
fix(api): strip trailing slash from VITE_API_BASE
Prevents a double slash (https://host//generate) when the env var is set with a trailing slash, which the backend 404s on. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 41bddda commit 6cdf0f0

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

frontend/src/api.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// In dev, calls go through the Vite proxy (/api -> http://localhost:8000).
22
// In production set VITE_API_BASE to the deployed backend origin
33
// (e.g. https://rtsgame-backend.onrender.com) at build time.
4-
const BASE = import.meta.env.VITE_API_BASE ?? '/api'
4+
// Strip any trailing slash so VITE_API_BASE="https://host/" doesn't produce a
5+
// double slash ("//generate") that the backend 404s on.
6+
const BASE = (import.meta.env.VITE_API_BASE ?? '/api').replace(/\/+$/, '')
57

68
export async function getCatalog() {
79
const res = await fetch(`${BASE}/catalog`)

0 commit comments

Comments
 (0)