🔌 point frontend proxy at remote backend
Browse files at this commit4edb34b86824da3d461ddb581e6b62549ef67947Parent: 113a858- fix
- 🔌 point frontend proxy at remote backend
4 changed files +6 -12
- README.md +2 -2
- compose.yaml +2 -8
- server.ts +1 -1
- vite.config.ts +1 -1
README.mdmodified+2 -2
| @@ -31,7 +31,7 @@ A modern, high-performance **SolidJS + TypeScript** web application for the Heza | |||
| 31 | ## 📦 Prerequisites & Setup | 31 | ## 📦 Prerequisites & Setup |
| 32 | 32 | ||
| 33 | - **Node.js** 20+ or **bun** (recommended) | 33 | - **Node.js** 20+ or **bun** (recommended) |
| 34 | -- Hezarfen backend running at `http://127.0.0.1:8080` (or proxied via Vite) | 34 | +- Access to the Hezarfen backend at `https://hezarfen.dizey.sh` |
| 35 | 35 | ||
| 36 | ### Installation & Development | 36 | ### Installation & Development |
| 37 | 37 | ||
| @@ -51,7 +51,7 @@ bun run build | |||
| 51 | 51 | ||
| 52 | Open [http://localhost:5173](http://localhost:5173) in your browser. | 52 | Open [http://localhost:5173](http://localhost:5173) in your browser. |
| 53 | 53 | ||
| 54 | -> **Proxy Note**: Vite server automatically proxies `/api/*` and WebSocket connections (`/ws/*`) to `http://127.0.0.1:8080`, preserving HttpOnly session cookies across same-origin calls. | 54 | +> **Proxy Note**: Vite server and the production Bun server proxy `/api/*` and WebSocket connections to `BACKEND_ORIGIN` (default: `https://hezarfen.dizey.sh`), preserving HttpOnly session cookies across same-origin calls. Override it when needed (`BACKEND_ORIGIN=http://127.0.0.1:7656 bun run dev` or `BACKEND_ORIGIN=http://host.containers.internal:7656 podman compose up -d --build`). |
| 55 | 55 | ||
| 56 | --- | 56 | --- |
| 57 | 57 | ||
compose.yamlmodified+2 -8
| @@ -9,8 +9,8 @@ services: | |||
| 9 | - "5173:5173" | 9 | - "5173:5173" |
| 10 | environment: | 10 | environment: |
| 11 | PORT: "5173" | 11 | PORT: "5173" |
| 12 | - # Backend on the shared compose network; server.ts proxies /api here. | 12 | + # Remote backend origin; server.ts keeps browser traffic same-origin. |
| 13 | - BACKEND_ORIGIN: "http://hezarfen-backend:8080" | 13 | + BACKEND_ORIGIN: "${BACKEND_ORIGIN:-https://hezarfen.dizey.sh}" |
| 14 | restart: unless-stopped | 14 | restart: unless-stopped |
| 15 | healthcheck: | 15 | healthcheck: |
| 16 | # Bun-based: the slim runtime image ships no curl. | 16 | # Bun-based: the slim runtime image ships no curl. |
| @@ -19,9 +19,3 @@ services: | |||
| 19 | timeout: 5s | 19 | timeout: 5s |
| 20 | retries: 3 | 20 | retries: 3 |
| 21 | start_period: 10s | 21 | start_period: 10s |
| 22 | - networks: | ||
| 23 | - - hezarfen_backend_default | ||
| 24 | - | ||
| 25 | -networks: | ||
| 26 | - hezarfen_backend_default: | ||
| 27 | - external: true | ||
server.tsmodified+1 -1
| @@ -8,7 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | const PORT = Number(Bun.env.PORT ?? 5173); | 9 | const PORT = Number(Bun.env.PORT ?? 5173); |
| 10 | // Where the backend lives on the compose network. Override in compose. | 10 | // Where the backend lives on the compose network. Override in compose. |
| 11 | -const BACKEND_ORIGIN = Bun.env.BACKEND_ORIGIN ?? "http://127.0.0.1:8080"; | 11 | +const BACKEND_ORIGIN = Bun.env.BACKEND_ORIGIN ?? "https://hezarfen.dizey.sh"; |
| 12 | const BACKEND_HTTP = BACKEND_ORIGIN.replace(/\/+$/, ""); | 12 | const BACKEND_HTTP = BACKEND_ORIGIN.replace(/\/+$/, ""); |
| 13 | const BACKEND_WS = BACKEND_HTTP.replace(/^http/, "ws"); | 13 | const BACKEND_WS = BACKEND_HTTP.replace(/^http/, "ws"); |
| 14 | const BACKEND_HOST = new URL(BACKEND_HTTP).host; | 14 | const BACKEND_HOST = new URL(BACKEND_HTTP).host; |
vite.config.tsmodified+1 -1
| @@ -2,7 +2,7 @@ import path from "node:path"; | |||
| 2 | import { defineConfig } from "vite"; | 2 | import { defineConfig } from "vite"; |
| 3 | import solid from "vite-plugin-solid"; | 3 | import solid from "vite-plugin-solid"; |
| 4 | 4 | ||
| 5 | -const target = "http://127.0.0.1:8080"; | 5 | +const target = process.env.BACKEND_ORIGIN ?? "https://hezarfen.dizey.sh"; |
| 6 | 6 | ||
| 7 | export default defineConfig({ | 7 | export default defineConfig({ |
| 8 | plugins: [solid()], | 8 | plugins: [solid()], |