mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-20 09:47:21 +02:00
♻️ Replace yarn with pnpm (#1693)
This commit is contained in:
parent
c8e78841f1
commit
765a97f3c6
59 changed files with 17816 additions and 16954 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue