Troubleshooting Remix Loader with Context Issue

What am I doing wrong? I'm trying to create a loader for Remix/React Router 7, but while my arguments are logged in the console, when I try to use them in a context, they are empty inside my effect, which leads to errors later on.

const LoaderArgs = Context.GenericTag<LoaderFunctionArgs>('LoaderArgs');

export async function loader(args: LoaderFunctionArgs) {
  console.log('args', args);
  
  return ServerRuntime.runPromise(
    T.gen(function* () {
      const { authenticator } = yield* AuthService.getAuth;
      const args2 = yield* LoaderArgs;

      yield* T.log('authenticating');
      yield* T.logInfo(args2.request);

      return yield* T.promise(() =>
        authenticator.authenticate('zitadel-openid', args2.request, {
          successRedirect: '/admin',
          failureRedirect: '/',
        })
      );
    }).pipe(T.provideService(LoaderArgs, args))
  );
}

export default function Login() {
  return <></>;
}
Was this page helpful?