Initial commit

This commit is contained in:
Harun CAN
2026-03-23 02:00:01 +03:00
commit d95b067fd9
195 changed files with 28288 additions and 0 deletions

42
middleware.ts Normal file
View File

@@ -0,0 +1,42 @@
import { withAuth } from "next-auth/middleware";
import createMiddleware from "next-intl/middleware";
import { routing } from "./src/i18n/routing";
const intlMiddleware = createMiddleware(routing);
const publicPages = ["/signin", "/signup"];
const authMiddleware = withAuth(
// Note: It is important to return the intlMiddleware to handle locale rewrites/redirects
(req) => intlMiddleware(req),
{
callbacks: {
authorized: ({ token }) => token != null,
},
pages: {
signIn: "/signin",
},
}
);
export default function middleware(req: any) {
const publicPathnameRegex = RegExp(
`^(/(${routing.locales.join("|")}))?(${publicPages
.flatMap((p) => (p === "/" ? ["", "/"] : p))
.join("|")})/?$`,
"i"
);
const isPublicPage = publicPathnameRegex.test(req.nextUrl.pathname);
if (isPublicPage) {
return intlMiddleware(req);
} else {
return (authMiddleware as any)(req);
}
}
export const config = {
// Skip all paths that should not be internationalized.
// This skips the folders "api", "_next" and all files with an extension (e.g. favicon.ico)
matcher: ["/((?!api|_next|.*\\..*).*)"],
};