Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 error in production, working fine in dev (Nuxt 3) #237

Open
skrypt-nl opened this issue Dec 30, 2021 · 13 comments
Open

404 error in production, working fine in dev (Nuxt 3) #237

skrypt-nl opened this issue Dec 30, 2021 · 13 comments

Comments

@skrypt-nl
Copy link

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/sitemap is in dependencies
  • Changed export default defineNuxtConfig( { ... } ) to module.exports = { ... } in nuxt.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
    }
}
@HelloAlexPan
Copy link

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

@skrypt-nl
Copy link
Author

@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.

@desaintflorent
Copy link

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.

@dargmuesli
Copy link

@NicoPennec @atinux I'd like to apply as maintainer for this repo too. Any chance for that to happen?

@pi0
Copy link
Member

pi0 commented Feb 2, 2022

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.

@Bjornnyborg
Copy link

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! 😊

Copy link
Member

atinux commented Feb 14, 2022

Any energy to make a PR to fix it @Bjornnyborg ?

@Bjornnyborg
Copy link

@atinux Thanks for the suggestion, but i don't think i have the insights and skills necessary to make this happen. 🤔

@dargmuesli
Copy link

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 nuxt-modules/robots#52 required or is there a feature to be waited for in nuxt framework? @pi0

@Bjornnyborg
Copy link

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.

@Fy-
Copy link

Fy- commented Apr 10, 2022

tmp fix: save the file in public/ and it works :')

@Ahmedelforjani
Copy link

is there anyone find a way to fix this bug ?

@d3xter-dev
Copy link

#248 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants