mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
Fix the feedback URL and stop serving a UI when WEB_STATIC=0
VITE_GATEWAY_URL names a WebSocket origin, and FEEDBACK_URL was derived
from it verbatim - so with VITE_GATEWAY_URL=wss://gateway.example the
form posted to wss://gateway.example/api/feedback, which fetch() refuses
outright ("TypeError: unknown scheme"). Every submission from a
separately hosted frontend failed before it left the browser. Map the
scheme back to http(s); an already-http VITE_GATEWAY_URL is untouched.
While there: WEB_STATIC=0 answered every path with the dev hint page,
which talks about localhost:5173 and npm run dev. That page is wrong for
a gateway that is reachable publicly, and an SPA-shaped answer on every
path makes the host look like a second, stale copy of the app. Serve a
short deployment-neutral notice at "/" and 404 everywhere else; the dev
hint stays for the case it is actually about, a missing web/dist.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
2ee6d1f0b5
commit
cc715e24b2
2 files changed
+28
-4
No files matched your search
+5
-2
@@ -86,11 +86,14 @@ const GATEWAY_URL = import.meta.env.DEV
|
||||
|
||||
// Same derivation as GATEWAY_URL above, but for a plain HTTP POST (the
|
||||
// feedback form) instead of the WebSocket - see gateway/src/index.ts's
|
||||
// /api/feedback handler.
|
||||
// /api/feedback handler. VITE_GATEWAY_URL names a WebSocket origin, so its
|
||||
// scheme has to be mapped back to http(s) here: fetch() refuses anything
|
||||
// else outright ("TypeError: unknown scheme"), so with VITE_GATEWAY_URL set
|
||||
// the form could not submit at all.
|
||||
const FEEDBACK_URL = import.meta.env.DEV
|
||||
? "http://localhost:8080/api/feedback"
|
||||
: import.meta.env.VITE_GATEWAY_URL
|
||||
? `${import.meta.env.VITE_GATEWAY_URL.replace(/\/$/, "")}/api/feedback`
|
||||
? `${import.meta.env.VITE_GATEWAY_URL.replace(/\/$/, "").replace(/^ws(s?):\/\//, "http$1://")}/api/feedback`
|
||||
: `${window.location.protocol}//${window.location.host}/api/feedback`;
|
||||
|
||||
// This file's frontend is deployed as multiple Cloudflare Pages projects
|
||||
|
||||
Reference in new issue
Block a user