Vinxi 0.5.7 + @solidjs/start 1.3.2 has a build bug where file-based API routes (src/routes/api/*) are registered in the page router tree but never mounted as Nitro handlers in the production build, so every /api/* request returns a framework 404. Fix: register a SolidStart middleware (src/middleware.ts) via the middleware config field. The middleware intercepts all /api/* paths and proxies them to the Rust gateway, bypassing the broken page router. Covers: - /api/gateway/* (catch-all proxy to gateway) - /api/kb/categories - /api/kb/articles - /api/kb/articles/:slug Also tightens the dev-server vite proxy from /api to /api/kb so it doesn't shadow the new middleware in dev. Removes the dead src/routes/api/ tree (no longer used).
28 lines
884 B
TypeScript
28 lines
884 B
TypeScript
/// <reference types="vitest/config" />
|
|
import { defineConfig } from "@solidjs/start/config";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
export default defineConfig({
|
|
// Register our Nitro middleware that handles all /api/* paths.
|
|
// Workaround for Vinxi 0.5.7 + @solidjs/start 1.3.2 build issue
|
|
// where file-based API routes are not mounted as Nitro handlers.
|
|
middleware: "./src/middleware.ts",
|
|
vite: {
|
|
plugins: [tailwindcss()],
|
|
server: {
|
|
proxy: {
|
|
"/api/gateway": {
|
|
target: "http://localhost:9100",
|
|
changeOrigin: true,
|
|
rewrite: (path) =>
|
|
path
|
|
.replace(/^\/api\/gateway\/api(\/|$)/, "/api$1")
|
|
.replace(/^\/api\/gateway(\/|$)/, "/api$1"),
|
|
},
|
|
"/api/kb": {
|
|
target: "http://localhost:9100",
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|