Skip to content

Instantly share code, notes, and snippets.

@KolbySisk
Created July 19, 2022 16:33
Show Gist options
  • Save KolbySisk/a7827eb34396a550e438ef5393d3f10c to your computer and use it in GitHub Desktop.
Save KolbySisk/a7827eb34396a550e438ef5393d3f10c to your computer and use it in GitHub Desktop.
import { NextRequest, NextResponse } from 'next/server';
export const middleware = async (request: NextRequest) => {
if (request.nextUrl.pathname.startsWith('/dashboard')) {
const authCookie = request.cookies.get('sb-access-token');
if (!authCookie) return NextResponse.redirect(new URL('/', request.url));
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment