#cloudflare workers + rr v7 + unstable_middleware

1 messages · Page 1 of 1 (latest)

lime gull
#

did it generate a getLoadContext somewhere in your project?

merry lion
#

I'm not using a getLoadContext function and just create the initial context inline.

https://github.com/mw10013/cloudflare-effect-react-router-saas/blob/main/functions/s/workers/app.ts#L34-L46

      const context = new unstable_RouterContextProvider();
      context.set(appLoadContext, {
        cloudflare: { env, ctx },
        auth,
        session:
          (await auth.api.getSession({ headers: c.req.raw.headers })) ??
          undefined,
      });
      const requestHandler = createRequestHandler(
        () => import("virtual:react-router/server-build"),
        import.meta.env.MODE,
      );
      return requestHandler(c.req.raw, context);

I wonder if you need to refactor your getLoadContext function to return a unstable_RouterContextProvider instead of an object per https://reactrouter.com/how-to/middleware#4-update-your-getloadcontext-function-if-applicable

GitHub

Contribute to mw10013/cloudflare-effect-react-router-saas development by creating an account on GitHub.