nuxt-hub / core

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

[admin] cache route not working #367

Closed remihuigen closed 2 weeks ago

remihuigen commented 2 weeks ago

Describe the bug the route /{team}/{project}/production/server/cache in admin app shows placeholder ("To enable cache storage ..."), even though cache is enabled in nuxt.config with hub.cache = true

Server cache itself is working correctly based on some testing. It's just an issue with the UI in the admin app.

├── @googlemaps/markerclusterer@2.5.3
├── @iconify-json/bxl@1.2.1
├── @iconify-json/heroicons@1.2.1
├── @iconify-json/material-symbols@1.2.5
├── @iconify-json/mdi@1.2.1
├── @nuxt/scripts@0.9.5
├── @nuxt/ui@2.18.7
├── @nuxthub/core@0.8.4
├── @nuxtjs/algolia@1.10.2
├── @nuxtjs/seo@2.0.0-rc.23
├── @vueuse/motion@2.2.6
├── nuxt@3.13.2
├── pinia@2.2.4
├── toucan-js@4.0.0
├── vue-router@4.4.5
├── vue@3.5.12 overridden
├── vue3-google-map@0.21.0
└── wrangler@3.82.0
atinux commented 2 weeks ago

When you open the browser console, what is the response of the XHR resquest?

remihuigen commented 2 weeks ago

On first load there is no request, see below (these are all fetch/XHR requests in the network tab) 👇

Screenshot 2024-11-04 at 15 49 09

If navigating to /cache from another route, there is a request to https://admin.hub.nuxt.com/api/teams/onderwijsin/projects/onderwijsloket-navigator/production/cache which responds with

{
    "url": "/api/teams/onderwijsin/projects/onderwijsloket-navigator/production/cache",
    "statusCode": 403,
    "statusMessage": "",
    "message": "[GET] \"https://onderwijsloket-navigator.nuxt.dev/api/_hub/cache\": 403 ",
    "stack": "",
    "data": {
        "url": "/api/_hub/cache",
        "statusCode": 403,
        "statusMessage": "",
        "message": "Missing Authorization header",
        "stack": ""
    }
}
atinux commented 2 weeks ago

Hey @remihuigen

I checked other routes (like /api/_hub/manifest) but I get the same 403 error, do you have any server middleware in your application that could strip the Authorization header somehow?

Or modules like nuxt-security or others?

remihuigen commented 2 weeks ago

@atinux Your suggestion put me on the right track! I was indeed stripping headers... I still used an old example for a custom $fetch plugin

Updating this code to follow the latest example fixed the issue