docs(api): Update nitro to latest version (#4102)

* update nitro

* try this?

* Try this

* update vercel output

* Add await

* Fix endpoints

* Adjust 404 catch all

* Fix output

* Adjust react in api

* Fix types

* Remove @resvg/resvg-wasm

* Format code

* Fix failing check

* Apply feedback

* Format code
This commit is contained in:
Eric Fennis
2026-03-05 14:03:27 +01:00
committed by GitHub
parent 0ea8780434
commit e6c7d7d495
27 changed files with 1205 additions and 1325 deletions
+23 -17
View File
@@ -22,24 +22,30 @@ const iconAliasesRedirectRoutes = Object.entries(iconMetaData)
};
});
const vercelRouteConfig = {
version: 3,
overrides: {},
cleanUrls: true,
routes: [
{
handle: 'filesystem',
},
{
src: '(?<url>/api/.*)',
dest: '/__nitro?url=$url',
},
...iconAliasesRedirectRoutes,
],
};
const vercelOutputJSON = path.resolve(currentDir, '.vercel/output/config.json');
const vercelConfig = await fs.promises.readFile(vercelOutputJSON, 'utf-8');
const vercelRouteConfig = JSON.parse(vercelConfig);
vercelRouteConfig.routes = [...iconAliasesRedirectRoutes, ...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.src === allCatchRoute);
if (fallBackIndex === -1) {
throw new Error(
`Could not find the expected catch-all route with src "${allCatchRoute}" in the existing Vercel config. Please make sure that the existing config has a catch-all route and that its src is "${allCatchRoute}".`,
);
}
vercelRouteConfig.routes[fallBackIndex].src = '/api/(.*)';
vercelRouteConfig.routes.push({
src: allCatchRoute,
dest: '/404.html',
});
const output = JSON.stringify(vercelRouteConfig, null, 2);
const vercelOutputJSON = path.resolve(currentDir, '.vercel/output/config.json');
await fs.promises.writeFile(vercelOutputJSON, output, 'utf-8');