fix: fix project access cache issue

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-10-18 15:00:00 +02:00
parent ea483d41a0
commit d8a297edf2
4 changed files with 551 additions and 17 deletions

View File

@@ -21,12 +21,6 @@ import { getCookiesFn } from '@/hooks/use-cookie-store';
import { useSessionExtension } from '@/hooks/use-session-extension';
import { op } from '@/utils/op';
import type { AppRouter } from '@openpanel/trpc';
import { createServerOnlyFn } from '@tanstack/react-start';
import {
getCookie,
getCookies,
getRequestHeaders,
} from '@tanstack/react-start/server';
import type { TRPCOptionsProxy } from '@trpc/tanstack-react-query';
op.init();

View File

@@ -12,23 +12,36 @@ import {
} from '@tanstack/react-router';
import { format } from 'date-fns';
const IGNORE_ORGANIZATION_IDS = [
'.well-known',
'robots.txt',
'sitemap.xml',
'favicon.ico',
'manifest.json',
'sw.js',
'service-worker.js',
'onboarding',
const IGNORE_ORGANIZATION_IDS = ['.well-known', 'onboarding', 'assets'];
const FILE_EXTENSIONS = [
'jpg',
'jpeg',
'png',
'gif',
'bmp',
'tiff',
'ico',
'js',
'xml',
'txt',
'json',
'webmanifest',
];
const isStaticFile = (path: string) => {
return FILE_EXTENSIONS.some((extension) => path.endsWith(`.${extension}`));
};
export const Route = createFileRoute('/_app/$organizationId')({
component: Component,
beforeLoad: async ({ context, params }) => {
if (IGNORE_ORGANIZATION_IDS.includes(params.organizationId)) {
throw notFound();
}
if (isStaticFile(params.organizationId)) {
throw notFound();
}
},
loader: async ({ context, params }) => {
await context.queryClient.prefetchQuery(