nuxt-modules / sitemap

Powerfully flexible XML Sitemaps that integrate seamlessly, for Nuxt.
https://nuxtseo.com/sitemap
322 stars 29 forks source link

help: The sitemap cannot be accessed in production #373

Open liuchuansmile opened 4 days ago

liuchuansmile commented 4 days ago

📚 What are you trying to do?

@nuxtjs/sitemap uses default configuration, not configured separately in nuxt.config.js

  1. My project is in SSR mode, running locally in yarn dev, with /preview access to the subdirectory sitemap
  2. But when you run it through node after yarn build, you no longer have access to subpaths Image Image

🔍 What have you tried?

No response

ℹī¸ Additional context

No response

rayblair06 commented 4 days ago

Have you set the site url correctly in defineNuxtConfig?

https://nuxtseo.com/sitemap/getting-started/installation

When you say production, do you just mean via yarn build command or is localhost always set no matter the environment?

If possible, it would be great if you could create a repo with your configuration either within Github or https://stackblitz.com/?

liuchuansmile commented 4 days ago

@rayblair06 Thanks for the reply. My local setup looks like this:

export default defineNuxtConfig({
  site: {
    url: `https://${PROD_DOMAIN}`,
    name: title,
  },
})

In fact, forgive me if I don't understand the configuration in the official documentation.

When I tried the simplest version on stackblitz, it seemed to work. This is weird. It looks like I have a local configuration conflict or a version issue?

My stackblitz projecit is : here

harlan-zw commented 4 days ago

As the Stackblitz reproduction is working there's not too much I can help with. Are you deploying with any specific nitro preset?

liuchuansmile commented 3 days ago

@harlan-zw it's just that

  nitro: {
    esbuild: {
      options: {
        target: 'esnext',
      },
    },
  },