Support configured sessions
H3 provides a useSession(event, config) utility which is useful to support authentication flows however its usage within Nitro apps is not intuitive because config needs to be manually handled and added.
We can support a Nitro configuration (which can be overridden with conventional runtime configs) for configured sessions.
To be used for upcoming h3 useSession(event, name = "default") (https://github.com/unjs/h3/issues/693)
So we could set this runtimeConfig:
runtimeConfig: {
session: {
default: {
name: 'my-session',
password: 'my-password-for-default-session'
}
}
Looks great to me!
Ye. I think putting the session definitions in nitro.config (or nuxt.config) And only for password use runtimeConfig/process.env.SERVER_SESSION_DEFAULT_PASSWORD.
Having definitions at built-time we can have more integrations and better predictable behavior for example for generating OpenAPI docs.