nuxt-modules / sitemap

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

Cloudflare Pages fix??? #380

Open DavidFrings opened 2 hours ago

DavidFrings commented 2 hours ago

Description:

I encountered the same issue as described in #259. After some investigation, I believe I have identified the cause.

While reviewing the dependencies unenv, h3, h3-compression, and sitemap, I found the following note in the README of the h3-compression package:

[!NOTE]
useCompressionStream doesn't work right now in Nitro. You should use useCompression instead.

Source

The relevant code in the sitemap module appears to be calling useCompressionStream:

import { useCompressionStream } from 'h3-compression'
import { defineNitroPlugin } from '#imports'

export default defineNitroPlugin((nitro) => {
  nitro.hooks.hook('beforeResponse', async (event, response) => {
    if (event.context._isSitemap)
      await useCompressionStream(event, response)    <-------------------------
  })
})

Source

Conclusion:

It seems like there's a mismatch between the method being used (useCompressionStream) and the functionality currently supported in h3-compression (which only supports useCompression). Replacing useCompressionStream with useCompression should resolve the issue.

I would really appreciate it if this could be fixed, but I'm not making the change myself as I'm not familiar with this module.

Let me know if you need further clarification.

DavidFrings commented 2 hours ago

🙏