fix: return JSON errors for unmatched local API routes

Test development and built-preview route registration, preserve development-only credential editing, and document local preview configuration.
This commit is contained in:
Sameh Khamis committed 2026-09-12 12:43:54 -07:00
1 parent a0f07b752f
commit 280fc00a51
8 files changed
+205 -4

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
/** Finish unmatched API requests before Vite's HTML fallback. Install last. */
export function apiNotFoundPlugin() {
const install = (server) => {
server.middlewares.use('/api', (_req, res) => {
res.writeHead(404, {
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
});
res.end(JSON.stringify({ error: 'Unknown API route' }));
});
};
return {
name: 'api-not-found',
configureServer: install,
configurePreviewServer: install,
};
}