This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 20
Configuring redis session #72
Labels
question
Further information is requested
Comments
Hi @gjedlicska, i tried this runtimeConfig for build production and didn't work.
He don't log the error message "can't connect ..." but save nothing on redis. Tks |
@gjedlicska i created this issue two weeks ago: #82 . I can't seem to figure this out. Would you have any ideas? |
@luukgruijs That's what I've started using. |
To provide a full example for anyone still struggling with this: {
modules: ['@sidebase/nuxt-session'],
// the build time config is needed, so that the nuxt module selects the right driver module during build
session: {
session: {
storageOptions: {
driver: 'redis',
options: {
}
}
}
},
// the runtime config is needed, to specify the shape of the config object.
// a dummy value for the url, that can be overridden by nuxt's runtime env var system
// https://nuxt.com/docs/guide/going-further/runtime-config#environment-variables
runtimeConfig: {
session: {
session: {
storageOptions: {
driver: 'redis',
options: {
// overriden by NUXT_SESSION_SESSION_STORAGE_OPTIONS_OPTIONS_URL env var
url: 'UNDEFINED' // you need to define the key, with a dummy value
}
}
}
}
}
} I'm adding a PR to update the readme with this. |
4 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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.The text was updated successfully, but these errors were encountered: