Files
aystone-manager/middleware.ts
T

23 lines
571 B
TypeScript
Raw Normal View History

2025-07-29 05:15:33 +02:00
import { auth } from "@/auth";
import { NextResponse } from "next/server";
export default auth((req) => {
const { pathname } = req.nextUrl;
if (pathname.startsWith("/dashboard") && !req.auth) {
return Response.redirect(
new URL("/api/auth/signin?callbackUrl=/dashboard", req.url)
);
}
const res = NextResponse.next();
res.headers.set("X-Frame-Options", "DENY");
res.headers.set("Content-Security-Policy", "frame-ancestors 'none';");
return res;
});
export const config = {
matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],
};