nuxt-hub / core

Build full-stack applications with Nuxt on CloudFlare, with zero configuration.
https://hub.nuxt.com
Apache License 2.0
993 stars 56 forks source link

Adding module nuxt-csurf breaks admin.hub.nuxt.com #255

Closed bitmanid closed 2 months ago

bitmanid commented 2 months ago

When the nuxt-csurf module is added to the project, it causes several issues with admin.hub.nuxt.com. Specifically:

atinux commented 2 months ago

Did you open an issue on the nuxt-csurf module?

Regarding nuxt/content, what is the error?

bitmanid commented 2 months ago

no, i haven't open the issue

this is error when i open path with nuxt-content

{
    "url": "/api/_content/query/2XsZFyQwbz.1725204537262.json?_params=%7B%22first%22:true,%22where%22:%5B%7B%22_path%22:%22%2Fterms-and-conditions%22%7D%5D,%22sort%22:%5B%7B%22_stem%22:1,%22$numeric%22:true%7D%5D%7D",
    "statusCode": 500,
    "statusMessage": "",
    "message": "[unstorage] [cloudflare] Invalid binding `CACHE`: `undefined`",
    "stack": ""
}
atinux commented 2 months ago

To fix the issue with csurf, you need to add this routeRules:

export default defineNuxtConfig({
  // ...
  routeRules: {
    '/api/_hub/**': {
      csurf: false
    }
  },
})

For the Invalid binding CACHE error, this is weird, did you deploy using NuxtHub CLI or through the NuxtHub Admin?

atinux commented 2 months ago

Even better, you can use the v0.7.9 to use nuxt-csurf with zero configuration :)

bitmanid commented 2 months ago

To fix the issue with csurf, you need to add this routeRules:

export default defineNuxtConfig({
  // ...
  routeRules: {
    '/api/_hub/**': {
      csurf: false
    }
  },
})

For the Invalid binding CACHE error, this is weird, did you deploy using NuxtHub CLI or through the NuxtHub Admin?

I'm using the Nuxthub CLI, and while the CSRF issue is resolved, I'm still unable to find a solution for nuxt/content.

atinux commented 2 months ago

Please create a small reproduction for nuxt/content so I can test