From 359a510c65e3f14e5490c4f09483b11839bbc4d0 Mon Sep 17 00:00:00 2001 From: SkateSpots Date: Mon, 28 Sep 2026 19:46:03 +0700 Subject: [PATCH] fix(dev): proxy /api/nip05 and /api/ai in the Vite dev server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both are production-only (Netlify Function + the CVM-host proxy), so on localhost the dev server answered them with index.html and the NIP-05 availability check showed 'Could not check right now' (and dev AI silently fell back to Pollinations). Proxying them to the real endpoints (as /api/mints already is) makes dev behave like prod. Verified: the check returns a real availability result and /api/ai/status returns the live Routstr balance. Dev-only config — the built output is unchanged, so the deploy guard skips it. --- AGENTS.md | 6 ++++++ vite.config.ts | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index a30592f..11a6ce2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -645,6 +645,12 @@ session with **no other memory of this project**. So: at `/api/mints/*` — prod proxies via `public/_redirects` (`/api/mints/* → https://mintradar.org/api/mints/:splat 200`), dev via `server.proxy` in `vite.config.ts`. Data is unofficial/rate-limited; adding a mint is native-only. + ⚠️ **`vite.config.ts`'s `server.proxy` also covers `/api/nip05` → + `https://skate-spots.org` and `/api/ai` → `https://ai.skate-spots.org` + (2026-09-28).** Without them the dev server answers those production-only + endpoints with `index.html`, so the NIP-05 availability check showed + **"Could not check right now"** on localhost and dev AI silently fell back to + Pollinations. (Prod is unaffected — the functions are same-origin there.) ⚠️ **Relative `/api/*` paths don't work in the native app** (fixed 2026-09-27): the shell is served from `https://localhost`, so `/api/mints/known` hits the LOCAL asset server and returns `index.html` → `Unexpected token '<' … not valid diff --git a/vite.config.ts b/vite.config.ts index d2e4113..b9a72cf 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -21,6 +21,20 @@ export default defineConfig(() => ({ changeOrigin: true, secure: true, }, + // /api/nip05 (the name registry) and /api/ai are PRODUCTION-only (Netlify + // Function + the CVM-host proxy). Without a dev proxy the dev server + // answers them with index.html, so the NIP-05 availability check failed + // locally with "Could not check right now" and dev AI never worked. + '/api/nip05': { + target: 'https://skate-spots.org', + changeOrigin: true, + secure: true, + }, + '/api/ai': { + target: 'https://ai.skate-spots.org', + changeOrigin: true, + secure: true, + }, }, }, plugins: [