-
Within the authenticator strategies, the request object is passed down, but for example if you want to get an environment variable on Cloudflare Pages with Remix you need to use the context object e.g.
how can this be accessed within the authenticator definition or strategies? Many examples show a secret being configured for the authenticator/strategy but assume you can use process.env from Node. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I found that context ( |
Beta Was this translation helpful? Give feedback.
-
When using it inside Cloudflare, I like to create a function or class that I can use to pass the env variables and create a new sessionStorage and Authenticator instance using those values, e.g. this is on my blog: Then when I need it I just call the class https://github.com/sergiodxa/sergiodxa.com/blob/3ba659ef8fab2995e6715ebb67b31586e020db8f/app/routes/_.auth.login.tsx#L21-L26 |
Beta Was this translation helpful? Give feedback.
I found that context (
AppLoadContext
) is supported in https://github.com/sergiodxa/remix-auth/blob/main/src/strategy.ts#L51 and it appears in some stragegies (e.g. remix-auth-jwt https://github.com/takagimeow/remix-auth-jwt/blob/main/src/index.ts#L40 ) it is supported, just not the particular strategy I was looking at.