sitemap-module
sitemap-module copied to clipboard
404 error in production, working fine in dev (Nuxt 3)
First let me say that I've checked out several other issues already, but none of the following solutions posted over there works. Some of this things I tried / made sure:
@nuxt/sitemapis independencies- Changed
export default defineNuxtConfig( { ... } )tomodule.exports = { ... }innuxt.config.ts
As stated in the title, /sitemap.xml is working perfectly fine in dev mode (npm run dev). However, when building the site (npm run build) and starting it (nuxi preview), the site returns my 404 page. The /sitemap_style.xsl file is available in production mode. It happens both on my local device as well as on my production server (NGINX reverse proxy). My thoughts are that this is a bug with Nuxt 3, but I cannot say this with 100% certainty.
This is my nuxt.config.ts sitemap object:
sitemap: {
xslUrl: '/sitemap_style.xsl',
routes: async () => {
const { data } = await axios.get('https://api.example.com') // this is the actual URL in my code, which is working
let routes = []
data.data.forEach((page) => {
let route = { url: page.slug, lastmod: page.date_updated }
routes.push(route)
})
return routes
}
}
bump, has there been any updates here? Our company is starting a fresh project on Nuxt 3 and have the capacity to help work on a Nuxt 3 build if there are any tasks that need to be completed
@HelloAlexPan no update on the issue yet unfortunately, but I downgraded my project back to Nuxt 2. Version 3 feels a little too instable and has too many small issues for a production ready site in my eyes.
If anyone find a fix to this bug I would be really interested ! Hope we will be able to use Sitemap Module with Nuxt 3 soon.
@NicoPennec @Atinux I'd like to apply as maintainer for this repo too. Any chance for that to happen?
Sitemap integration with Nuxt3/Nitro needs some additional hooks to generate support that is not stable yet until we can move to use nitro pack (https://github.com/nuxt/framework/discussions/1690)
Thanks for your interest @HelloAlexPan @desaintflorent @dargmuesli to maintain repo 💚
I will try to contact the module author (@NicoPennec) to see how we can work together and support Nuxt3.
Also experiencing this problem in this project: https://github.com/enterspeedhq/enterspeed-demo-nuxt3 Works great in dev, but throws a 404 in production: https://enterspeed-demo-nuxt3.netlify.app/sitemap.xml
Would be awesome to have this fixed! 😊
Any energy to make a PR to fix it @Bjornnyborg ?
@Atinux Thanks for the suggestion, but i don't think i have the insights and skills necessary to make this happen. 🤔
I'm not quite sure what "some additional hooks to generate support" and "until we can move to use nitro pack" mean specifically. Is something like https://github.com/nuxt-community/robots-module/pull/52 required or is there a feature to be waited for in nuxt framework? @pi0
Since it works in develop, i would guess that the problem is something to do with not using the proper hook in nuxt3 production?
In my project i have dynamic routing controlled by Enterspeed, so i was able to just make a simple script (triggered by a build:before hook) that fetches my routes from the API and using the sitemap.js module write a sitemap.xml to the public folder.
tmp fix: save the file in public/ and it works :')
is there anyone find a way to fix this bug ?
https://github.com/nuxt-community/sitemap-module/issues/248#issuecomment-1169105131