This repository was archived by the owner on Dec 12, 2023. It is now read-only.
This repository was archived by the owner on Dec 12, 2023. It is now read-only.
Configuring redis session #72
Open
Description
Ask your question
Should the working example below be the officially recommended way of configuring a nuxt-session?
Additional information
Using the example below based on the docs for configuring the redis session storage is partially broken / misleading.
// file: ~/nuxt.config.ts
export default defineNuxtConfig({
modules: ['@sidebase/nuxt-session'],
session: {
session: {
storageOptions: {
driver: 'redis',
options: {
url: process.env['REDIS_URL']
}
}
}
}
})
It is working well in a local dev setup, but breaks, when the app is built into a docker container. Most probably, because at build time, we deliberately do not supply the value of the REDIS_URL
env var, the storage driver falls back to its default value.
I've found, that the config is actually read via nuxt's useRuntimeConfig
function and supplying the config below, makes it work in both local and prod setups.
export default defineNuxtConfig({
modules: ['@sidebase/nuxt-session'],
runtimeConfig: {
session: {
session: {
storageOptions: {
driver: 'redis',
options: {
url: () => process.env['REDIS_URL']
}
}
}
}
}
})