| 1 | import type { NextRequest } from 'next/server' |
| 2 | |
| 3 | export const PUBLIC_ROUTES: |
| 4 | '/', |
| 5 | '/api/og', |
| 6 | '/polar/webhooks', |
| 7 | '/opengraph-image', |
| 8 | '/twitter-image', |
| 9 | '/sitemap.xml', |
| 10 | '/manifest.webmanifest', |
| 11 | ] |
| 12 | export const AUTH_PREFIX: |
| 13 | export const API_AUTH_PREFIX: |
| 14 | export const DEFAULT_LOGIN_REDIRECT: |
| 15 | |
| 16 | export function isApiAuth(pathname |
| 17 | return startsWith(pathname |
| 18 | } |
| 19 | |
| 20 | export function isAuthRoute(pathname |
| 21 | return startsWith(pathname |
| 22 | } |
| 23 | |
| 24 | export function isPublicRoute(pathname |
| 25 | return isPathEqual(pathname |
| 26 | } |
| 27 | |
| 28 | // Utils |
| 29 | function isPathEqual(pathname: |
| 30 | return paths.includes |
| 31 | } |
| 32 | |
| 33 | function startsWith(pathname: |
| 34 | return pathname.startsWith |
| 35 | } |
| 36 | |
| 37 | export function getSignInUrl(request |
| 38 | const rt = |
| 39 | return new URL |
| 40 | `${AUTH_PREFIX}/sign-in?redirectTo=${encodeURIComponent |
| 41 | request.url |
| 42 | ) |
| 43 | } |