feat: full studio build -- light theme, canvas thumbnails, i18n (fa/en)

This commit is contained in:
Soroush.Asadi
2026-05-24 17:37:21 +03:30
parent d962483359
commit c61f587767
295 changed files with 29797 additions and 265 deletions
+36
View File
@@ -0,0 +1,36 @@
import { type NextRequest } from "next/server";
import createIntlMiddleware from "next-intl/middleware";
import { routing } from "@/i18n/routing";
import { updateSession } from "@/lib/supabase/middleware";
const handleI18n = createIntlMiddleware(routing);
export async function middleware(request: NextRequest) {
// 1. Run i18n locale detection / redirect
const i18nResponse = handleI18n(request);
// If next-intl redirected (e.g. to add /en/ prefix), honour it immediately
if (i18nResponse.status !== 200 || i18nResponse.headers.has("location")) {
return i18nResponse;
}
// 2. Run Supabase session refresh on the (possibly rewritten) request
const supabaseResponse = await updateSession(request);
// Carry over any locale cookies/headers set by next-intl
i18nResponse.headers.forEach((value, key) => {
if (!supabaseResponse.headers.has(key)) {
supabaseResponse.headers.set(key, value);
}
});
return supabaseResponse;
}
export const config = {
// Match all routes except api, _next, static assets
matcher: [
"/((?!api|_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
],
};