Skip to content

Instantly share code, notes, and snippets.

View f1729's full-sized avatar
Everything is possible!

Luis f1729

Everything is possible!
  • Peru
View GitHub Profile
@f1729
f1729 / _middleware.ts
Created November 9, 2022 20:36 — forked from mtt87/_middleware.ts
Add password protection to any Vercel website, save $150/month.
import { addYears } from 'date-fns'
import { NextRequest, NextResponse } from 'next/server'
function middleware(req: NextRequest) {
if (req.nextUrl.pathname.startsWith('/api')) {
return NextResponse.next()
}
if (process.env.VERCEL_ENV !== 'preview') {
return NextResponse.next()