-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
I migrated from version 3.1.1 to 4.0.2 of nuxt-multi-cache following the migration guide, but now i'm not able to use composable useRuntimeConfig in \server\multiCache.serverOptions.ts anymore.
When i run my project with npm run dev i got the error:
[nuxt] A composable that requires access to the Nuxt instance was called outside of a plugin, Nuxt hook, Nuxt middleware, or Vue setup function. This is probably not a Nuxt bug. Find out more at https://nuxt.com/docs/guide/concepts/auto-imports#vue-and-nuxt-composables`.`
While if i build and release the project it works without problems.
I use it to get the redis connection parameters.
Is there any other way to use it?
import { defineMultiCacheOptions } from "nuxt-multi-cache/server-options";
import redisDriver from "unstorage/drivers/redis";
import type { RedisOptions } from "unstorage/drivers/redis";
const config = useRuntimeConfig();
let redisDriverOpts: RedisOptions;
redisDriverOpts = {
db: parseInt(config.REDIS_CACHE_DB),
host: config.REDIS_CACHE_HOST,
port: parseInt(config.REDIS_CACHE_PORT),
};
export default defineMultiCacheOptions(() => {
return {
route: {
storage: {
driver: redisDriver({
...redisDriverOpts,
base: `${config.REDIS_CACHE_PREFIX}:route:`,
}),
},
},
data: {
storage: {
driver: redisDriver({
...redisDriverOpts,
base: `${config.REDIS_CACHE_PREFIX}:data:`,
}),
},
},
};
});
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels