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

routeRules > cache > getKey lost in the process of delivery #1660

Closed
William-WFC opened this issue Aug 29, 2023 · 5 comments
Closed

routeRules > cache > getKey lost in the process of delivery #1660

William-WFC opened this issue Aug 29, 2023 · 5 comments

Comments

@William-WFC
Copy link

William-WFC commented Aug 29, 2023

I read the issue #977 .
But I find getKey still invalid in routeRules > cache, in nitro.config.js
here is my config

nitro: {
        devStorage: {
            'v_pc': {
                driver: 'redis',
                /* redis connector options */
                port: 6379, // Redis port
                host: 'localhost', // Redis host
                db: 0, // Defaults to 0
                maxRetriesPerRequest: 2,
            },
        },
        routeRules: {
            '/**': {
                cache: {
                    name: 'my_name',
                    swr: false,
                    maxAge: 6 * 60,
                    base: 'v_pc',
                    getKey: () => 'hhhiii',
                },
            },
        },
    },

I console.log in here (in route-rules.mjs file),

const config = useRuntimeConfig();
console.log('config.nitro.routeRules', config.nitro.routeRules)
const _routeRulesMatcher = toRouteMatcher(
  createRadixRouter({ routes: config.nitro.routeRules })
);

getKey is lost

config.nitro.routeRules {
  '/__nuxt_error': { cache: false },
  '/**': { cache: { name: 'my_name', swr: false, maxAge: 360, base: 'v_pc' } }
}

I guess this is a bug. getKey is lost In the process of delivery.

### Tasks
- [ ] https://github.com/unjs/nitro/issues/977
@pi0
Copy link
Member

pi0 commented Aug 29, 2023

Thanks for detailed issue dear @William-WFC but would you please also attach a minimal reproduction?

@pi0 pi0 added the nuxt label Aug 29, 2023
@William-WFC
Copy link
Author

Thanks for detailed issue dear @William-WFC but would you please also attach a minimal reproduction?

here is reproduction.

https://stackblitz.com/edit/nuxt-starter-v6wnbq?file=nuxt.config.ts,app.vue

the cache file in .nuxt/cache/nitro/routes/my_test should be hhhiii.json, as configured in nuxt.config.ts.
but actually it's index.il7asoJjJE.json

@lxccc812
Copy link

Is there any answer?

@MiniDigger
Copy link
Contributor

I think this is a duplicate of #1048

@pi0
Copy link
Member

pi0 commented May 14, 2024

Let's track with #1048

non serializable values in route rules such as functions cannot be passed from config to runtime.

@pi0 pi0 closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants