commerce/middleware.ts
Chloe 8333eb36fc
clean up unused code and create login callback api endpoints
Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
2024-06-22 15:09:35 +07:00

16 lines
481 B
TypeScript

import { getOrigin, isLoggedIn } from 'lib/shopify/auth';
import type { NextRequest } from 'next/server';
// This function can be marked `async` if using `await` inside
export async function middleware(request: NextRequest) {
if (request.nextUrl.pathname.startsWith('/account')) {
console.log('Running Account middleware');
const origin = getOrigin(request);
return await isLoggedIn(request, origin);
}
}
export const config = {
matcher: ['/account/:path*']
};