-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.ts
More file actions
34 lines (26 loc) · 999 Bytes
/
proxy.ts
File metadata and controls
34 lines (26 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
const ORIGIN = 'https://ticketping.com';
/**
* 308 permanent redirects to ticketping.com (docs now live at /docs on the main site).
* Skips Next.js/Vercel internals so assets keep serving from this host when needed.
*/
export function proxy(request: NextRequest) {
const { pathname, search } = request.nextUrl;
if (pathname.startsWith('/_next') || pathname.startsWith('/_vercel')) {
return NextResponse.next();
}
if (pathname === '/') {
return NextResponse.redirect(`${ORIGIN}/docs${search}`, 308);
}
if (pathname.startsWith('/docs')) {
return NextResponse.redirect(`${ORIGIN}${pathname}${search}`, 308);
}
if (pathname.startsWith('/api')) {
return NextResponse.redirect(`${ORIGIN}${pathname}${search}`, 308);
}
return NextResponse.redirect(`${ORIGIN}/docs${pathname}${search}`, 308);
}
export const config = {
matcher: ['/', '/((?!_next/|_vercel/).*)'],
};