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

fix(remix): RequestInit.duplex now is required if body is provided in undici #3495

5 changes: 5 additions & 0 deletions .changeset/fifty-parents-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/remix': patch
---

Fix RequestInit.duplex which now is required if body is provided in undici
3 changes: 2 additions & 1 deletion packages/remix/src/ssr/authenticateRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { AuthenticateRequestOptions, SignedInState, SignedOutState } from '
import { AuthStatus } from '@clerk/backend/internal';

import type { LoaderFunctionArgs } from './types';
import { patchRequest } from './utils';

export async function authenticateRequest(
args: LoaderFunctionArgs,
Expand All @@ -23,7 +24,7 @@ export async function authenticateRequest(
domain,
publishableKey,
userAgent: `${PACKAGE_NAME}@${PACKAGE_VERSION}`,
}).authenticateRequest(request, {
}).authenticateRequest(patchRequest(request), {
audience,
authorizedParties,
signInUrl,
Expand Down
3 changes: 2 additions & 1 deletion packages/remix/src/ssr/loadOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import { isTruthy } from '@clerk/shared/underscore';
import { noSecretKeyError, satelliteAndMissingProxyUrlAndDomain, satelliteAndMissingSignInUrl } from '../utils/errors';
import { getEnvVariable } from '../utils/utils';
import type { LoaderFunctionArgs, RootAuthLoaderOptions } from './types';
import { patchRequest } from './utils';

export const loadOptions = (args: LoaderFunctionArgs, overrides: RootAuthLoaderOptions = {}) => {
const { request, context } = args;
const clerkRequest = createClerkRequest(request);
const clerkRequest = createClerkRequest(patchRequest(request));

// Fetch environment variables across Remix runtime.
// 1. First check if the user passed the key in the getAuth function or the rootAuthLoader.
Expand Down
15 changes: 15 additions & 0 deletions packages/remix/src/ssr/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,18 @@ export function getResponseClerkState(requestState: RequestStateWithRedirectUrls
export const wrapWithClerkState = (data: any) => {
return { clerkState: { __internal_clerk_state: { ...data } } };
};