forge
Explore
Log in

Don't you dare go Hollow

🔌 point the dev proxy at the public backend by default

Browse files at this commit

896684b6f8babd60f04650d85183686f284fb008Burak BoduroğluParent: 0a51c44
  • chore
    • 🔌 point the dev proxy at the public backend by default
Show full message
chore: 🔌 point the dev proxy at the public backend by default
- `bun run dev` now works without a local Rust backend; opt into one with
  BACKEND_ORIGIN=http://127.0.0.1:7656
- keep stripping /api for direct backends and leave it alone for the public
  frontend origin, which terminates /api itself
vite.config.tsmodified+8 -5
@@ -2,7 +2,11 @@ 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 = process.env.BACKEND_ORIGIN ?? "http://127.0.0.1:7656";5+// Keep zero-config local development usable even when the Rust backend is not
6+// running on this machine. Deployments use server.ts and the image-level
7+// BACKEND_ORIGIN instead; developers can still opt into a local backend with
8+// BACKEND_ORIGIN=http://127.0.0.1:7656 bun run dev.
9+const target = process.env.BACKEND_ORIGIN ?? "https://hezarfen-backend.dizey.sh";
6 10
7 export default defineConfig({11 export default defineConfig({
8 plugins: [solid()],12 plugins: [solid()],
@@ -27,10 +31,9 @@ export default defineConfig({
27 target,31 target,
28 changeOrigin: true,32 changeOrigin: true,
29 ws: true,33 ws: true,
30- // Local Rust backend (e.g. :7656) speaks unprefixed routes, so strip34+ // Direct backends (local or public) speak unprefixed routes, so strip
31- // /api. The public origin terminates /api itself — stripping there35+ // /api. The public frontend origin terminates /api itself — stripping
32- // hits the SPA HTML instead of the API and breaks every local session36+ // there hits the SPA HTML instead of the API.
33- // against the default BACKEND_ORIGIN.
34 rewrite: (path) => {37 rewrite: (path) => {
35 try {38 try {
36 if (/hezarfen\.dizey\.sh$/i.test(new URL(target).host)) return path;39 if (/hezarfen\.dizey\.sh$/i.test(new URL(target).host)) return path;