sidebase / nuxt-session

Nuxt session middleware to get a persistent session per app user, e.g., to store data across multiple requests. The nuxt session module provides the useSession() composable out of the box and sets up API endpoints to interact with your session to make working with sessions feel like a breeze.
https://sidebase.io/nuxt-session/
MIT License
188 stars 19 forks source link

connect to storage drivers (a.k.a redis) through environment variables #82

Closed luukgruijs closed 1 year ago

luukgruijs commented 1 year ago

Ask your question

I'm running into an issue where i seem to be unable to provide environment variables for connecting to redis. We run a multi environment setup where each environment has their own connection string for redis. i've tried things like:

    session: {
      expiryInSeconds: 60 * 60, // 3600
      rolling: true, // reset expiryInSeconds when client is active
      storageOptions: {
        driver: "redis",
        options: {
          url: `${process.env.NUXT_APP_CACHE_HOST}:${process.env.NUXT_APP_CACHE_PORT}`,
          ttl: 60 * 60,
        },
      },
    },

as well as

    session: {
      expiryInSeconds: 60 * 60, // 3600
      rolling: true, // reset expiryInSeconds when client is active
      storageOptions: {
        driver: "redis",
        options: {
          url: () => `${process.env.NUXT_APP_CACHE_HOST}:${process.env.NUXT_APP_CACHE_PORT}`,
          ttl: 60 * 60,
        },
      },
    },

as well as

 storageOptions: {
        driver: "redis",
        options: {
          url: () => `${process.env["NUXT_APP_CACHE_HOST"]}:${process.env["NUXT_APP_CACHE_PORT"]}`,
          ttl: 60 * 60,
        },
      },

All seem to be compiled during build time. Is there a way to configure this connection to redis through the runtimeConfig of nuxt?

If you give me some pointers i would also be happy to contribute with an MR.

Thanks in advance.

Additional information

No response

luukgruijs commented 1 year ago

answer in #72