NuxtN
Nuxt8mo ago
22 replies
Davide Marchet

[SOLVED] Failed to parse URL from sitemap.xml at node:internal/deps/undici/undici....

Hi,
Every build (dev and prod) shows this (non-blocking) error:

9:51:36 AM: [error] Failed to parse URL from sitemap.xml
9:51:36 AM:   at node:internal/deps/undici/undici:12637:11
9:51:36 AM:   [cause]: Invalid URL
9:51:36 AM:     at new NodeError (node:internal/errors:405:5)
9:51:36 AM:     at new URL (node:internal/url:676:13)
9:51:36 AM:     at new Request (node:internal/deps/undici/undici:6119:25)
9:51:36 AM:     at fetch (node:internal/deps/undici/undici:10415:25)
9:51:36 AM:     at Object.fetch (node:internal/deps/undici/undici:12636:10)
9:51:36 AM:     at fetch (node:internal/process/pre_execution:281:25)
9:51:36 AM:     at localFetch (.nuxt/prerender/chunks/nitro/nitro.mjs:3312:25)
9:51:36 AM:     at generateRoute (node_modules/.pnpm/nitropack@2.11.11/node_modules/nitropack/dist/core/index.mjs:2047:23)
9:51:36 AM:     at node_modules/.pnpm/nitropack@2.11.11/node_modules/nitropack/dist/core/index.mjs:1502:128
9:51:36 AM:     at async Promise.all (index 0)


Here’s my current Nitro configuration:
nitro: {
    routeRules: {
      '/**': { isr: true },
    },
    prerender: {
      autoSubfolderIndex: true,
      concurrency: 1,
      interval: 1,
      failOnError: false,
      crawlLinks: true,
      ignore: [],
      routes: ["/", "sitemap.xml"],
      retries: 4,
      retryDelay: 1000,
    },
    preset: "netlify-edge",
  },


And my Nuxt sitemap configuration:

  sitemap: {
    siteUrl: process.env.SITE_URL, // the value is the domain or localhost if in locale
    sources: ["/api/sitemap"],
  },

The /api/sitemap handler currently returns an empty array for testing:

  export default defineSitemapEventHandler((e) => {
    const urls = [];
    return urls.flat();
  });


Even when I return valid URLs, the error still appears.
Have you encountered this issue? Any advice would be appreciated!

Thanks and regards,
Davide
Was this page helpful?