mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-13 13:48:26 +00:00
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:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user