Closed bitmanid closed 2 months ago
Did you open an issue on the nuxt-csurf
module?
Regarding nuxt/content, what is the error?
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": ""
}
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?
Even better, you can use the v0.7.9 to use nuxt-csurf
with zero configuration :)
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.
Please create a small reproduction for nuxt/content so I can test
When the nuxt-csurf module is added to the project, it causes several issues with admin.hub.nuxt.com. Specifically:
Every request to /api/teams/ returns a 403 Forbidden error, indicating that a CSRF token is required, even though I have configured routeRules in nuxt.config to apply CSRF protection only to certain API paths.
The nuxt/content module is also affected. Requests to paths using ContentDoc always return a 500 Internal Server Error. The issue seems to be related to Cloudflare caching. Disabling caching with hub: { cache: false } resolves the error with nuxt/content, but the admin interface still breaks.