feat(dev): serve Vite and FastAPI through the existing UI endpoint
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
# Existing s2s-client FastAPI server. Used only by Vite's server-side proxy.
|
||||
S2S_BACKEND_URL=http://127.0.0.1:8420
|
||||
# Comma-separated hostnames, only needed when accessing Vite through a remote host.
|
||||
# FastAPI target when running npm run dev independently. start_ui.sh sets this
|
||||
# to its own backend using S2S_BACKEND_PORT (default 8421).
|
||||
S2S_BACKEND_URL=http://127.0.0.1:8421
|
||||
# Comma-separated hostnames for remote access, without scheme or port.
|
||||
# With start_ui.sh this can also be set in the repository root .env.
|
||||
S2S_DEV_ALLOWED_HOSTS=
|
||||
|
||||
@@ -4,9 +4,9 @@ import { createBackendProxy } from "../../config/backend-proxy";
|
||||
|
||||
describe("development backend proxy", () => {
|
||||
it("keeps the public host and original paths for the FastAPI runtime URL", () => {
|
||||
const proxy = createBackendProxy("http://127.0.0.1:8420");
|
||||
expect(proxy["/api"]).toEqual({ target: "http://127.0.0.1:8420", changeOrigin: false });
|
||||
expect(proxy["/v1/realtime"]).toEqual({ target: "http://127.0.0.1:8420", changeOrigin: false, ws: true });
|
||||
const proxy = createBackendProxy("http://127.0.0.1:8421");
|
||||
expect(proxy["/api"]).toEqual({ target: "http://127.0.0.1:8421", changeOrigin: false });
|
||||
expect(proxy["/v1/realtime"]).toEqual({ target: "http://127.0.0.1:8421", changeOrigin: false, ws: true });
|
||||
expect(proxy["/openapi.json"]).toEqual(proxy["/api"]);
|
||||
expect(proxy["/oauth"]).toEqual(proxy["/api"]);
|
||||
});
|
||||
|
||||
@@ -14,13 +14,14 @@ export default defineConfig(({ mode }) => {
|
||||
resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)) } },
|
||||
server: {
|
||||
host: "127.0.0.1",
|
||||
port: 5173,
|
||||
port: 8420,
|
||||
strictPort: true,
|
||||
ws: { path: "/__vite_hmr" },
|
||||
allowedHosts: (env.S2S_DEV_ALLOWED_HOSTS ?? "")
|
||||
.split(",")
|
||||
.map((host) => host.trim())
|
||||
.filter(Boolean),
|
||||
proxy: createBackendProxy(env.S2S_BACKEND_URL ?? "http://127.0.0.1:8420"),
|
||||
proxy: createBackendProxy(env.S2S_BACKEND_URL ?? "http://127.0.0.1:8421"),
|
||||
},
|
||||
build: { target: "es2022" },
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user