You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When accessing args.context.env from a loader we expect this to contain environment variables loaded from .dev.vars
Actual Behavior
The 2.7.0 release seems to make the getLoadContext function optional in createPagesFunctionHandler. The expectation according to the release notes is that this will bring the implementation inline with the vite setup and correctly default to loading context.env.
However, this is not the case. The reasoning seems to be that the default implementation of getLoadContext is (context) => ({ env: context }). The correct implementation actually seems to be ({ context }) => ({ env: context.cloudflare.env }) since both the input arguments and context type seem to have changed in the latest release.
To be clear, this is what shows up in the cloudflare-pages template for server.ts
Just a question, I see in the PR that you've marked the old args passed to getLoadContext as deprecated. To maintain compatibility with v3 going forward, is it expected that we use getLoadContext: ({ context }) => ({ env: context.cloudflare.env })?
Reproduction
https://github.com/AdiRishi/remix-2.7.0-env-bug
System Info
Used Package Manager
pnpm
Expected Behavior
When accessing
args.context.env
from a loader we expect this to contain environment variables loaded from.dev.vars
Actual Behavior
The
2.7.0
release seems to make thegetLoadContext
function optional increatePagesFunctionHandler
. The expectation according to the release notes is that this will bring the implementation inline with the vite setup and correctly default to loadingcontext.env
.However, this is not the case. The reasoning seems to be that the default implementation of
getLoadContext
is(context) => ({ env: context })
. The correct implementation actually seems to be({ context }) => ({ env: context.cloudflare.env })
since both the input arguments and context type seem to have changed in the latest release.To be clear, this is what shows up in the
cloudflare-pages
template forserver.ts
A correct
server.ts
looks like thisI've demonstrated this in the reproduction repository as well.
The text was updated successfully, but these errors were encountered: