hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits
| 1 | import path from "node:path"; |
| 2 | import { defineConfig } from "vite"; |
| 3 | import solid from "vite-plugin-solid"; |
| 4 | |
| 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"; |
| 10 | |
| 11 | export default defineConfig({ |
| 12 | plugins: [solid()], |
| 13 | resolve: { |
| 14 | alias: { |
| 15 | "@": path.resolve(__dirname, "./src"), |
| 16 | }, |
| 17 | }, |
| 18 | server: { |
| 19 | // Chromium 150's HTTP cache deadlocks when a page that fans out to ~230 |
| 20 | // separately-served, `no-cache`-revalidated dev modules (kobalte/corvu |
| 21 | // ship unbundled) is reloaded a handful of times in a row: after ~7 |
| 22 | // reloads its cache entries wedge and every later request queues in the |
| 23 | // browser forever — no bytes ever reach vite. `no-store` stops Chromium |
| 24 | // from creating the cache entries at all. Dev-only; the production build |
| 25 | // is served by Bun (server.ts) with its own cache headers. |
| 26 | headers: { |
| 27 | "Cache-Control": "no-store", |
| 28 | }, |
| 29 | proxy: { |
| 30 | "/api": { |
| 31 | target, |
| 32 | changeOrigin: true, |
| 33 | ws: true, |
| 34 | // Direct backends (local or public) speak unprefixed routes, so strip |
| 35 | // /api. The public frontend origin terminates /api itself — stripping |
| 36 | // there hits the SPA HTML instead of the API. |
| 37 | rewrite: (path) => { |
| 38 | try { |
| 39 | if (/hezarfen\.dizey\.sh$/i.test(new URL(target).host)) return path; |
| 40 | } catch { |
| 41 | /* keep strip fallback */ |
| 42 | } |
| 43 | return path.replace(/^\/api(?=\/|$)/, ""); |
| 44 | }, |
| 45 | }, |
| 46 | }, |
| 47 | }, |
| 48 | build: { |
| 49 | target: "esnext", |
| 50 | }, |
| 51 | }); |