This is my nuxt.config.ts when i am using hook of “prerender:routes” my build is getting stucked both locally and on any hosting platform Build Stucked Image
import { defineNuxtConfig } from 'nuxt/config';
export default defineNuxtConfig({
compatibilityDate: '2024-04-03',
devtools: { enabled: true },
plugins: ['~/plugins/vuetify.js'],
build: {
transpile: ['vuetify'],
},
runtimeConfig: {
public: {
dbUrl: process.env.DB_URL,
}
},
css: [
'vuetify/styles',
'@mdi/font/css/materialdesignicons.css',
],
ssr: false,
nitro: {
routeRules: {
'/': { isr: true },
'/contact': { ssr: false },
'/projects': { isr: true },
},
preset:'netlify',
},
hooks: {
async "prerender:routes" (ctx){
try {
const response = await fetch('https://nuxt-project-sandy.vercel.app/api/getAllProjects');
if (!response.ok) {
throw new Error('Network response was not ok');
}
const projects = await response.json();
projects.forEach((project: { _id: string }) => {
ctx.routes.add(`/project/${project._id}`);
});
} catch (error) {
console.error('Error fetching projects:', error);
}
}
},
});
I am removing the hooks and hardcoding a single route
routeRules: {
'/': { isr: true },
'/contact': { ssr: false },
'/projects': { isr: true },
'/project/66e0120073ecac4add9472bc':{prerender:true}
},
and even after using this my build is still getting stucked at the particular line.
1