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

Dynamic URL Endpoint not working with bun preset #346

Open
charbs-io opened this issue Nov 5, 2024 · 0 comments
Open

Dynamic URL Endpoint not working with bun preset #346

charbs-io opened this issue Nov 5, 2024 · 0 comments

Comments

@charbs-io
Copy link

Describe the bug

Hi,

I've been using nuxt-seo for 6 months on a production website. I generate my sitemaps using the built-in "Dynamic URL Endpoint" feature.

My site is hosted on Railway and use the node-server preset for Nitro.

export default defineNuxtConfig({
  sitemap: {
    sitemaps: {
      articles: {
        defaults: {
          changefreq: "yearly",
          priority: 0.9,
        },
        sources: [
          [
            `${process.env.API_BASE_URL}/api/sitemap/articles`,
            {
              headers: {
                "x-auth-token": process.env.SERVER_AUTH_SECRET_KEY as string,
              },
            },
          ],
        ],
      },
      pages: {
        includeAppSources: true,
        defaults: {
          changefreq: "daily",
          priority: 0.9,
        },
        sources: [
          [
            `${process.env.API_BASE_URL}/api/sitemap/pages`,
            {
              headers: {
                "x-auth-token": process.env.SERVER_AUTH_SECRET_KEY as string,
              },
            },
          ],
        ],
      },
    },
  },
});

This has been working with absolutely no issues.

This morning I changed the nitro preset to bun in an effort to test a few things not related to sitemaps or SEO (memory consumption, build times etc), and everything worked except for the sitemap generation.

When I visit my sitemap in production, i get this error in my logs:

[@nuxtjs/sitemap] Failed to fetch source. {
  url: "https://myapi.com/api/sitemap/articles";,
  error: FetchError: [GET] "https://myapi.com/api/sitemap/articles";: 404 Not Found,
}

Locally, I don't have any of these issues (i.e the URL is found, and the auth header is passed and utilised correctly).

What is bizarre is that the url being passed is actually https://myapi.com/api/sitemap/articles" (note the double quotes at the end) hence why it's returning 404.

This is potentially not a nuxt-seo issue, but thought i'd ask here in case someone has seen this before.

I went through the nuxt-seo source code, and the error returned is from src/runtime/nitro/sitemap/urlset/sources.ts line 65. I can't see anything obvious about why it's failing or why the url value is being passed incorrectly.

Appreciate any help or insights.

Reproduction

No response

System / Nuxt Info

No response

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

1 participant