Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Ability to retrieve values without wrapping loaders and actions #19

Open
MattyBalaam opened this issue Aug 27, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@MattyBalaam
Copy link

MattyBalaam commented Aug 27, 2024

I was wondering if there might be the possibility of providing methods for directly accessing values via the request object, avoiding the need to wrap every loader or action just to call an API for example.

This is based on the assumption that the route remix loader can handle being an auth gateway, so it is not required to be used on every single child loader.

import type { LoaderFunctionArgs } from '@remix-run/node';
import { json } from '@remix-run/node';
import { getAccessToken } from '@workos-inc/authkit-remix';

export const loader = async ({request } : LoaderFunctionArgs) => {

    const serviceData = await fetch('/api/path', {
      headers: {
        Authorization: `Bearer ${await getAccessToken(request)}`,
      },
    });

    return json({
      data: serviceData,
    });
  });

Or perhaps:

const auth = await getAuthKitContext(args);
const token = auth.getAccessToken()
@MattyBalaam MattyBalaam changed the title Feature request: Ability to retrieve values without wrapping loader Feature request: Ability to retrieve values without wrapping loaders and actions Aug 29, 2024
@PaulAsjes PaulAsjes added the enhancement New feature or request label Aug 29, 2024
@PaulAsjes
Copy link
Collaborator

Thanks for this, that's a great idea. Will add this to the roadmap!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants