chore(uniweb): make pnpm dev usable after the same-origin switch
Same-origin (Caddy) means the SPA reaches /api and /nats through its own origin in production, but those relative paths do not exist on the bare Vite dev server, so `pnpm dev` no longer connects. busService already reads VITE_BUS_HTTP / VITE_BUS_WS as overrides of the same-origin defaults — this documents that path (Option A, no proxy code) and moves the dev server off the port reserved by an unrelated local app. - vite.config: dev server port 5173 -> 5174 (5173 is in use by another local app). strictPort left off so Vite falls back to the next free port. Comment explains the same-origin/dev split and the env-var override. - app.md: Ejemplo and the CORS gotcha document the exact dev command (VITE_BUS_HTTP/WS pointing at a cluster node) on :5174 and the same-origin production model. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+9
-5
@@ -3,12 +3,16 @@ import react from "@vitejs/plugin-react";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
// The SPA talks DIRECTLY to the bus (signed HTTPS control plane + nats.ws data
|
||||
// plane), so there is no gateway and no /api proxy. The dev server runs on 5173 to
|
||||
// match the bus CORS allowlist (--cors-origins http://localhost:5173). Point the
|
||||
// SPA at a cluster node with VITE_BUS_HTTP / VITE_BUS_WS (see busService.ts).
|
||||
// In production the SPA is served same-origin behind Caddy, which proxies /api and
|
||||
// /nats to the cluster; those relative paths do not exist on the bare dev server, so
|
||||
// `pnpm dev` must be pointed at a real cluster node with VITE_BUS_HTTP / VITE_BUS_WS
|
||||
// (busService.ts uses them as overrides of the same-origin defaults). Example:
|
||||
// VITE_BUS_HTTP=https://<node>:8470 VITE_BUS_WS=wss://<node>:8480 pnpm dev
|
||||
// The dev server runs on 5174 (5173 is reserved for an unrelated local app). Add the
|
||||
// dev origin (http://localhost:5174) to the node's --cors-origins allowlist. strictPort
|
||||
// is left off, so Vite falls back to the next free port if 5174 is busy.
|
||||
server: {
|
||||
host: true,
|
||||
port: 5173,
|
||||
port: 5174,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user