Repository navigation
fix: config url - #8304
fix: config url#8304
Conversation
| const defaultBackendTarget = 'http://127.0.0.1:8080/' | ||
| const projectRoot = fileURLToPath(new URL('.', import.meta.url)) | ||
|
|
||
| const renameHtmlPlugin = (outDir: string, entry: string) => { |
There was a problem hiding this comment.
The diff shows a single change: the default backend target for the Vite dev proxy was changed from https://mkv3-ee.fit2cloud.cn/ to http://[IP]:8080/.
Irregularities / issues:
-
[IP]is a placeholder, not a valid host. As written,http://[IP]:8080/will fail if left unresolved. Note that[IP]in brackets looks like an IPv6 literal, butIPis not valid hex, so URL parsing may throw or the proxy will simply fail to connect. Either substitute a real address or use a clearly-invalid-but-unambiguous placeholder (e.g.,http://localhost:8080/). -
Loss of TLS. The original used
https://; the new default uses plainhttp://. If the backend still serves HTTPS, this will break (connection refused / protocol error). Confirm the backend actually speaks HTTP on 8080. -
Committed placeholder in source code. Hardcoding
[IP]in a tracked config file risks it being accidentally shipped or confusing other developers. Prefer driving the target from an environment variable (loadEnvis already imported) rather than editing the source per developer/machine. -
Trailing slash. The original had a trailing
/;http://[IP]:8080/also does — just make sure the proxy rewrite logic expects (or normalizes) the trailing slash consistently, since path joining can double slashes otherwise. -
Port change implication. Moving to port 8080 suggests a different service than the original production host. Ensure any cookie/CORS/origin expectations (cookies domain, redirect URLs) match, as dev-proxy behavior changes when host/port/scheme change.
Optimization suggestions:
- Replace the hardcoded constant with an env-driven value, e.g.:
and document it in
const defaultBackendTarget = process.env.VITE_BACKEND_TARGET ?? 'http://localhost:8080/'
.env.example. - Validate the target at startup (e.g.,
new URL(defaultBackendTarget)) to surface misconfiguration early. - If IP-based access is needed, use the fully qualified address (
http://192.168.x.x:8080/) and avoid bracket syntax unless truly using IPv6. - Add a brief comment explaining why the default differs from production, to prevent future confusion.
No structural problems with the surrounding code are visible from this fragment itself — the concerns above all stem from the changed value.
fix: config url