Skip to content

Commit

Permalink
chore(astro): Ignore prerendered routes in Astro v4
Browse files Browse the repository at this point in the history
  • Loading branch information
wobsoriano committed Dec 2, 2024
1 parent 666953d commit 4aaddc1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/astro/src/server/clerk-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const clerkMiddleware: ClerkMiddleware = (...args: unknown[]): any => {

const astroMiddleware: AstroMiddleware = async (context, next) => {
// if the current page is prerendered, do nothing
if ('isPrerendered' in context && context.isPrerendered) {
if (isPrerenderedPage(context)) {
return next();
}

Expand Down Expand Up @@ -129,6 +129,15 @@ export const clerkMiddleware: ClerkMiddleware = (...args: unknown[]): any => {
return astroMiddleware;
};

const isPrerenderedPage = (context: APIContext) => {
return (
// for Astro v5
('isPrerendered' in context && context.isPrerendered) ||
// for Astro v4
('_isPrerendered' in context && context._isPrerendered)
);
};

// TODO-SHARED: Duplicate from '@clerk/nextjs'
const parseHandlerAndOptions = (args: unknown[]) => {
return [
Expand Down

0 comments on commit 4aaddc1

Please sign in to comment.