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

fix(AWS-Lambda) "The specified key does not exist" when open /sitemap.xml on production #431

Open
dpetrovaliev opened this issue Mar 13, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@dpetrovaliev
Copy link

dpetrovaliev commented Mar 13, 2025

🐛 The bug

I'm having issue with opening the sitemap on production. Here is the result I receive:

404 Not Found

<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>sitemap.xml</Key>
<RequestId>2S3ZG9JNRSA8Q05V</RequestId>
<HostId>ZPmgliGJsKYfSe7tD6mpWlxC6VxvTAgOs5AQkEVcs+7PSpEi5uAPlX8XqxL9XNT7Coj8TLVgwMA=</HostId>
</Error>

🛠️ To reproduce

plantsnap.com/sitemap.xml

🌈 Expected behavior

To see the sitemap generated by the module instead if receiving 404 Not Found

ℹ️ Additional context

Here is part of my nuxt config:

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: "2024-11-01",
  devtools: { enabled: true },

  nitro: {
    preset: "aws-lambda",
  },

  modules: [
    "@nuxtjs/tailwindcss",
    "@pinia/nuxt",
    "@pinia-plugin-persistedstate/nuxt",
    "@nuxtjs/seo",
    "@sentry/nuxt/module",
    "nuxt-api-shield",
    "@nuxtjs/sitemap",
    "nuxt-gtag",
    "@nuxt/scripts",
    "@nuxtjs/robots",
  ],

  robots: {
    sitemap: ["/sitemap.xml"],
  },

  sitemap: {
    siteUrl: process.env.APP_URL,
    sitemaps: {
      posts: {
        sources: ["/api/__sitemap__/urls/posts"],
      },
      pages: {
        sources: ["/api/__sitemap__/urls/pages"],
        exclude: [
          "/unsubscribe",
          "/vote-for-this-weeks-top-community-post",
          "/apga-garden-marketing-materials-copy",
        ],
      },
      categories: {
        sources: ["/api/__sitemap__/urls/categories"],
      },
      galleries: {
        sources: ["/api/__sitemap__/urls/galleries"],
      },
    },
  },

//.....

  sourcemap: {
    client: "hidden",
  },

  site: {
    url: process.env.APP_URL,
    defaultLocale: "en",
  },
});

@dpetrovaliev dpetrovaliev added the bug Something isn't working label Mar 13, 2025
@harlan-zw harlan-zw changed the title fix: "The specified key does not exist" when open /sitemap.xml on production fix(AWS-Lambda) "The specified key does not exist" when open /sitemap.xml on production Mar 14, 2025
@harlan-zw
Copy link
Collaborator

Hey, looks like maybe you solved this? I was going to suggest it was likely an AWS lambda config issue (i.e it thinks sitemap.xml should be a static file)

@dpetrovaliev
Copy link
Author

Hey, looks like maybe you solved this? I was going to suggest it was likely an AWS lambda config issue (i.e it thinks sitemap.xml should be a static file)

No I didn't find a solution yet. Actually how this plugin works does it registers an ssr route to provide the sitemap data or how?

@harlan-zw
Copy link
Collaborator

Your reproduction looks fine though? plantsnap.com/sitemap.xml

Yes it's a SSR route, you can choose to prerender the /sitemap.xml path if you prefer it static

@dpetrovaliev
Copy link
Author

Your reproduction looks fine though? plantsnap.com/sitemap.xml

Yes it's a SSR route, you can choose to prerender the /sitemap.xml path if you prefer it static

Yes, this is what I did, I uploaded a static file on S3 currently loaded at the /sitemap.xml endpoint.
But still can't figure it out why this is not working. maybe it's related to my cloudfront configuration which is setup to serve the ssr routes only on /api endpoint.

What do you mean by "you can choose to prerender the /sitemap.xml path if you prefer it static"?

@harlan-zw
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants