📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Enable future flags
Blue Moused5fac42528b6
diff --git a/web/app/i18n.ts b/web/app/i18n.tsindex 450a4a873..208ca97f6 100644--- a/web/app/i18n.ts+++ b/web/app/i18n.ts@@ -24,9 +24,10 @@ const genericConfig: InitOptions = {},}-export function detectLanguage(request: Request): string {- const url = new URL(request.url)-+export function detectLanguage(+ request: Request,+ url = new URL(request.url),+): string {// Stage 1: Getting the language from the URL path prefix (/de/page).const pathLang = getLangFromPath(url.pathname)if (pathLang) {diff --git a/web/app/root.tsx b/web/app/root.tsxindex 57836731d..43421644a 100644--- a/web/app/root.tsx+++ b/web/app/root.tsx@@ -371,16 +371,14 @@ const buildLocaliseRedirect = (return null}-export async function loader({ request }: LoaderFunctionArgs) {- const { url } = request+export async function loader({ request, url: urlObject }: LoaderFunctionArgs) {+ const url = urlObject.toString()const removedLng = removeMultipleLngParams(url)if (removedLng !== url) {return redirect(removedLng, 301)}- const urlObject = new URL(url)-if (!isSelfhosted && isWWW(urlObject)) {const nonWWWLink = _replace(url, 'www.', '')const httpToHttps = _replace(nonWWWLink, 'http://', 'https://')@@ -392,7 +390,7 @@ export async function loader({ request }: LoaderFunctionArgs) {return redirect(localiseRedirect.url, localiseRedirect.status)}- const locale = detectLanguage(request)+ const locale = detectLanguage(request, urlObject)const theme = detectTheme(request)const hasTokens = hasAuthTokens(request)diff --git a/web/app/routes/$.tsx b/web/app/routes/$.tsxindex 34d005c22..2cb7964e3 100644--- a/web/app/routes/$.tsx+++ b/web/app/routes/$.tsx@@ -40,7 +40,7 @@ export const sitemap: SitemapFunction = () => ({exclude: true,})-export async function loader({ request, params }: LoaderFunctionArgs) {+export async function loader({ request, params, url }: LoaderFunctionArgs) {const catchAllPath = params['*']if (!catchAllPath) {@@ -54,14 +54,12 @@ export async function loader({ request, params }: LoaderFunctionArgs) {if (lang) {const stripped = catchAllPath.slice(`${lang}/`.length)if (stripped) {- const url = new URL(request.url)return redirect(`/${stripped}${url.search}`, 301)}} else if (catchAllPath.startsWith(`${defaultLanguage}/`)) {// /en/imprint → /imprint (default language is never present in the path)const stripped = catchAllPath.slice(`${defaultLanguage}/`.length)if (stripped) {- const url = new URL(request.url)return redirect(`/${stripped}${url.search}`, 301)}}diff --git a/web/app/routes/demo.tsx b/web/app/routes/demo.tsxindex 3e3cfb305..e440f99ab 100644--- a/web/app/routes/demo.tsx+++ b/web/app/routes/demo.tsx@@ -12,8 +12,8 @@ export const sitemap: SitemapFunction = () => ({exclude: true,})-export const loader = async ({ request }: LoaderFunctionArgs) => {- const lang = getLangFromPath(new URL(request.url).pathname)+export const loader = async ({ url }: LoaderFunctionArgs) => {+ const lang = getLangFromPath(url.pathname)const demoPath = lang ? localisePath(LIVE_DEMO_URL, lang) : LIVE_DEMO_URLreturn redirect(`${MAIN_URL}${demoPath}`)diff --git a/web/react-router.config.ts b/web/react-router.config.tsindex bb492c8bd..ff10d0561 100644--- a/web/react-router.config.ts+++ b/web/react-router.config.ts@@ -3,5 +3,10 @@ import type { Config } from '@react-router/dev/config'export default {future: {unstable_optimizeDeps: true,+ v8_middleware: true,+ v8_splitRouteModules: true,+ v8_viteEnvironmentApi: true,+ v8_passThroughRequests: true,+ v8_trailingSlashAwareDataRequests: true,},} satisfies Config