Skip to content

Commit

Permalink
fixup! chore(clerk-js): Simplify dev browser handling
Browse files Browse the repository at this point in the history
  • Loading branch information
SokratisVidros committed Dec 14, 2023
1 parent a954168 commit c16d653
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
30 changes: 15 additions & 15 deletions packages/clerk-js/src/core/devBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ export function createDevBrowser({ frontendApi, fapiClient }: CreateDevBrowserOp
return;
}

// 1. Set network interceptors to Pass dev
fapiClient.onBeforeRequest(request => {
const devBrowserJWT = getDevBrowserJWT();
if (devBrowserJWT && request?.url) {
request.url = setDevBrowserJWTInURL(request.url, devBrowserJWT, true);
}
});

fapiClient.onAfterResponse((_, response) => {
const newDevBrowserJWT = response?.headers?.get('Clerk-Db-Jwt');
if (newDevBrowserJWT) {
setDevBrowserJWT(newDevBrowserJWT);
}
});

// 1. If a cookie already exists, it might have SameSite=Strict. Re-set it to make sure it has SameSite=Lax
const existingDevBrowserCookie = getDevBrowserCookie();
if (existingDevBrowserCookie) {
Expand Down Expand Up @@ -78,21 +93,6 @@ export function createDevBrowser({ frontendApi, fapiClient }: CreateDevBrowserOp

const data = await resp.json();
setDevBrowserJWT(data?.token);

fapiClient.onBeforeRequest(request => {
const devBrowserJWT = getDevBrowserJWT();
if (devBrowserJWT && request?.url) {
request.url = setDevBrowserJWTInURL(request.url, devBrowserJWT, true);
}
});

fapiClient.onAfterResponse((_, response) => {
// TODO: Rename header to Clerk-DB-JWT in FAPI
const newDevBrowserJWT = response?.headers?.get('Clerk-Cookie');
if (newDevBrowserJWT) {
setDevBrowserJWT(newDevBrowserJWT);
}
});
}

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/ui/customizables/parseVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const createFontSizeScale = (theme: Theme): Record<keyof typeof fontSizes
return {
xs: (numericValue * 0.6875).toString() + unit,
sm: (numericValue * 0.75).toString() + unit,
md: (numericValue * 0.8125).toString() + unit,
md: (numericValue * 1).toString() + unit,
lg: (numericValue * 1.0625).toString() + unit,
xl: (numericValue * 1.5).toString() + unit,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/src/server/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { apiUrlFromPublishableKey } from '@clerk/shared/apiUrlFromPublishableKey
import { isTruthy } from '@clerk/shared/underscore';

export const CLERK_JS_VERSION = process.env.NEXT_PUBLIC_CLERK_JS_VERSION || '';
export const CLERK_JS_URL = process.env.NEXT_PUBLIC_CLERK_JS || '';
export const CLERK_JS_URL = process.env.NEXT_PUBLIC_CLERK_JS_URL || '';
export const API_VERSION = process.env.CLERK_API_VERSION || 'v1';
export const SECRET_KEY = process.env.CLERK_SECRET_KEY || '';
export const PUBLISHABLE_KEY = process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY || '';
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/src/utils/mergeNextClerkPropsWithEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const mergeNextClerkPropsWithEnv = (props: Omit<NextClerkProviderProps, '
return {
...props,
publishableKey: props.publishableKey || process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY || '',
clerkJSUrl: props.clerkJSUrl || process.env.NEXT_PUBLIC_CLERK_JS,
clerkJSUrl: props.clerkJSUrl || process.env.NEXT_PUBLIC_CLERK_JS_URL,
clerkJSVersion: props.clerkJSVersion || process.env.NEXT_PUBLIC_CLERK_JS_VERSION,
proxyUrl: props.proxyUrl || process.env.NEXT_PUBLIC_CLERK_PROXY_URL || '',
domain: props.domain || process.env.NEXT_PUBLIC_CLERK_DOMAIN || '',
Expand Down

0 comments on commit c16d653

Please sign in to comment.