alternative to process.env in cloudflare pages
# pages-help
s
Does anyone have a good pattern for using
createSessionStorage
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`:
Copy code
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?