♻️ Replace yarn with pnpm (#1693)

This commit is contained in:
Luke Vella 2025-04-27 15:16:38 +01:00 committed by GitHub
parent c8e78841f1
commit 765a97f3c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
59 changed files with 17816 additions and 16954 deletions

View file

@ -1,6 +1,6 @@
import languages from "@rallly/languages";
import { getPreferredLocale } from "@rallly/languages/get-preferred-locale";
import { withPostHog } from "@rallly/posthog/next/middleware";
import { getPosthogBootstrapCookie } from "@rallly/posthog/utils";
import { NextResponse } from "next/server";
import { withAuth } from "@/auth/edge";
@ -19,7 +19,12 @@ export const middleware = withAuth(async (req) => {
return NextResponse.redirect(newUrl);
}
const locale = req.auth?.user?.locale || getPreferredLocale(req);
const locale =
req.auth?.user?.locale ||
getPreferredLocale({
acceptLanguageHeader: req.headers.get("accept-language") ?? undefined,
});
if (supportedLocales.includes(locale)) {
newUrl.pathname = `/${locale}${pathname}`;
}
@ -29,7 +34,12 @@ export const middleware = withAuth(async (req) => {
res.headers.set("x-pathname", pathname);
if (req.auth?.user?.id) {
await withPostHog(res, { distinctID: req.auth.user.id });
const bootstrapCookie = getPosthogBootstrapCookie({
distinctID: req.auth.user.id,
});
if (bootstrapCookie) {
res.cookies.set(bootstrapCookie);
}
}
return res;