fix(frontend): anchor Vite dev proxy so /login.html isn't forwarded

The /login proxy entry was matching any path starting with /login —
including /login.html, which Vite is supposed to serve itself. Without
the Go backend running, this caused ECONNREFUSED noise on every page
load.

Switched to regex patterns anchored with ^...$ so only the bare backend
paths (/login, /logout, /getTwoFactorEnable) and explicit sub-routes
(/panel/*, /server/*) get proxied. Static .html files Vite serves
directly are no longer matched.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
MHSanaei 2026-05-08 11:55:40 +02:00
parent ebe57ef273
commit 1faecbe1dd
No known key found for this signature in database
GPG key ID: 7E4060F2FBE5AB7A

View file

@ -32,10 +32,11 @@ export default defineConfig({
strictPort: true,
proxy: {
// Proxy API calls during `npm run dev` to the local Go panel.
'/panel': 'http://localhost:2053',
'/server': 'http://localhost:2053',
'/login': 'http://localhost:2053',
'/logout': 'http://localhost:2053',
// Patterns are anchored regex so /login.html and /index.html
// (which Vite serves itself) are NOT forwarded — only the bare
// backend paths and their sub-routes.
'^/(login|logout|getTwoFactorEnable)$': 'http://localhost:2053',
'^/(panel|server)(/|$)': 'http://localhost:2053',
},
},
});