mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
tweak prefetch on links
This commit is contained in:
@@ -118,6 +118,7 @@ export default async function RootLayout({ children, params }: LayoutProps) {
|
|||||||
<Link
|
<Link
|
||||||
href="/browse"
|
href="/browse"
|
||||||
className="hover:underline focus-within:underline underline-offset-2 decoration-[.5px] font-light px-2"
|
className="hover:underline focus-within:underline underline-offset-2 decoration-[.5px] font-light px-2"
|
||||||
|
prefetch={false}
|
||||||
>
|
>
|
||||||
Browse
|
Browse
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -8,42 +8,47 @@ export async function middleware(request: NextRequest) {
|
|||||||
const domain = request.nextUrl.hostname;
|
const domain = request.nextUrl.hostname;
|
||||||
const config = await getConfig(domain);
|
const config = await getConfig(domain);
|
||||||
|
|
||||||
// Feature-flag protedted paths
|
|
||||||
if (
|
if (
|
||||||
!config.features.browse &&
|
request.nextUrl.pathname.match(
|
||||||
request.nextUrl.pathname.startsWith("/browse")
|
"/((?!api|_next/static|_next/image|favicon.ico).*)",
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
return NextResponse.redirect(request.nextUrl.origin);
|
// Feature-flag protedted paths
|
||||||
}
|
if (
|
||||||
|
!config.features.browse &&
|
||||||
|
request.nextUrl.pathname.startsWith("/browse")
|
||||||
|
) {
|
||||||
|
return NextResponse.redirect(request.nextUrl.origin);
|
||||||
|
}
|
||||||
|
|
||||||
if (config.features.requireLogin) {
|
if (config.features.requireLogin) {
|
||||||
const fiefMiddleware = await getFiefAuthMiddleware(request.nextUrl);
|
const fiefMiddleware = await getFiefAuthMiddleware(request.nextUrl);
|
||||||
const fiefResponse = await fiefMiddleware(request);
|
const fiefResponse = await fiefMiddleware(request);
|
||||||
|
|
||||||
|
if (
|
||||||
|
request.nextUrl.pathname == "/" ||
|
||||||
|
request.nextUrl.pathname.startsWith("/transcripts") ||
|
||||||
|
request.nextUrl.pathname.startsWith("/browse")
|
||||||
|
) {
|
||||||
|
if (!fiefResponse.headers.get("x-middleware-rewrite")) {
|
||||||
|
fiefResponse.headers.set(
|
||||||
|
"x-middleware-rewrite",
|
||||||
|
request.nextUrl.origin + "/" + domain + request.nextUrl.pathname,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fiefResponse;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
request.nextUrl.pathname == "/" ||
|
request.nextUrl.pathname == "/" ||
|
||||||
request.nextUrl.pathname.startsWith("/transcripts") ||
|
request.nextUrl.pathname.startsWith("/transcripts") ||
|
||||||
request.nextUrl.pathname.startsWith("/browse")
|
request.nextUrl.pathname.startsWith("/browse")
|
||||||
) {
|
) {
|
||||||
if (!fiefResponse.headers.get("x-middleware-rewrite")) {
|
return NextResponse.rewrite(
|
||||||
fiefResponse.headers.set(
|
request.nextUrl.origin + "/" + domain + request.nextUrl.pathname,
|
||||||
"x-middleware-rewrite",
|
);
|
||||||
request.nextUrl.origin + "/" + domain + request.nextUrl.pathname,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
console.log(fiefResponse);
|
|
||||||
}
|
}
|
||||||
return fiefResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
request.nextUrl.pathname == "/" ||
|
|
||||||
request.nextUrl.pathname.startsWith("/transcripts") ||
|
|
||||||
request.nextUrl.pathname.startsWith("/browse")
|
|
||||||
) {
|
|
||||||
return NextResponse.rewrite(
|
|
||||||
request.nextUrl.origin + "/" + domain + request.nextUrl.pathname,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.next();
|
return NextResponse.next();
|
||||||
|
|||||||
Reference in New Issue
Block a user