sohebrapati
05/21/2023, 2:35 AMcreateSessionStorage
in an environment that requires passing in the context
?
Specifically, I'm using cloudflare-pages and have environment variables. Cloudflare doesn't make process.env
available; instead, the environment variables come in through the loader context
.
The best I can come up with is wrapping createSessionStorage
in a function that takes a `context`:
const sessionManager = sessionManagerFor(context)
const session = sessionManager.getSession(request.headers.get('cookie'))
…
return json('stuff', {
headers: {
'set-cookie': sessionManager.commitSession,
}
})
Is that the "most Remix-ey" way to do it?