https://github.com/miteyema/nuxt-sitemap-now
This is the config object for sitemap in nuxt.config.js:
sitemap: {
hostname: baseURL,
defaults: {
lastmod: new Date(),
changefreq: 'weekly',
priority: 0.8
}
}
The generate part in nuxt.config.js:
generate: {
async routes() {
const response = await axios.get('routes', {
// FYI: generate will always be in production mode
baseURL: apiBaseURL
})
const dynamicRoutes = response.data
return dynamicRoutes
}
}
sitemap.xml is shown
"Nuxt.js Internal Server Error" is show with status code 500.
The following log is shown on the server:
ERROR Cannot read property 'filter' of null
at node_modules/@nuxtjs/sitemap/lib/routes.js:14:21
at Array.forEach (<anonymous>)
at excludeRoutes (node_modules/@nuxtjs/sitemap/lib/routes.js:11:12)
at Object.cache.staticRoutes (node_modules/@nuxtjs/sitemap/lib/middleware.js:48:30)
at AsyncCache.load [as _load] (node_modules/@nuxtjs/sitemap/lib/cache.js:19:68)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
@miteyema which version on this following doc, do you use to deploy?
https://nuxtjs.org/faq/now-deployment/
v2 or v1?
@NicoPennec That would be v2. I have made a repo (configured with now) with nuxt and only your sitemap module and I still have the same error:
Repo: https://github.com/miteyema/nuxt-sitemap-now
URL: https://nuxt-sitemap.now.sh/sitemap.xml
I'm having a very similar issue where it's working locally however when it's in a live environment I am also getting Zeit Now internal server error. Though our sitemap module config is slightly different:
/**
** Sitemap module
*/
sitemap: {
// routes: async () => {
// const routes = await getRoutes()
// return routes
// },
// Still does not work if I hardcode the routes
routes: ['/', 'journal', '/journal/overview', '/journal/medical', '/journal/wellness', '/locations'],
hostname: baseUrl,
path: '/sitemap.xml',
gzip: true,
generate: false,
}
I believe this has been an issue for a few weeks since I first looked at the Sitemap, but have been working on other stuff since. May have to create my own sitemap.xml with a serverless function as we're going to be launching on Thursday
[GET] /sitemap.xml
13:02:42:32
ERROR Cannot read property 'map' of null
at joinRoutes (node_modules/@nuxtjs/sitemap/lib/cache.js:76:31)
at AsyncCache.load [as _load] (node_modules/@nuxtjs/sitemap/lib/cache.js:19:18) (repeated 1 times)
ERROR Cannot read property 'map' of null
at joinRoutes (node_modules/@nuxtjs/sitemap/lib/cache.js:76:31)
at AsyncCache.load [as _load] (node_modules/@nuxtjs/sitemap/lib/cache.js:19:18)
@miteyema thanks for your very complete report ๐
I will investigate the root cause.
(issue linked to https://github.com/nuxt-community/sitemap-module/pull/95)