Adjust 404 catch all

This commit is contained in:
Eric Fennis
2026-02-26 15:31:29 +01:00
parent 68afe65eef
commit 40dd406524
2 changed files with 10 additions and 3 deletions
-3
View File
@@ -1,3 +0,0 @@
export default eventHandler(() => {
return { nitro: 'Is Awesome! asda' };
});
+10
View File
@@ -34,6 +34,16 @@ vercelRouteConfig.routes = [
...vercelRouteConfig.routes,
]
// Adjust the existing catch-all route to only catch API routes, so that we can add a new catch-all route for 404s
const allCatchRoute = '/(.*)';
const fallBackIndex = vercelRouteConfig.routes.findIndex(route => route.handle === allCatchRoute);
vercelRouteConfig.routes[fallBackIndex].src = '/api/(.*)'
vercelRouteConfig.routes.push({
src: allCatchRoute,
dest: '/404.html',
})
const output = JSON.stringify(vercelRouteConfig, null, 2);
await fs.promises.writeFile(vercelOutputJSON, output, 'utf-8');