Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions apps/frontend/src/middleware/project.global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ export default defineNuxtRouteMiddleware(async (to) => {
const projectId = to.params.id as string

try {
// Fetch v2 project for redirect check AND cache it for the page
// Using fetchQuery ensures the page's useQuery gets this cached result
const project = await queryClient.fetchQuery(projectQueryOptions.v2(projectId, client))
const projectV3 = await queryClient.fetchQuery(projectQueryOptions.v3(projectId, client))
// Fetch v2 and v3 in parallel — cache both for the page's useQuery calls
const [project, projectV3] = await Promise.all([
queryClient.fetchQuery(projectQueryOptions.v2(projectId, client)),
queryClient.fetchQuery(projectQueryOptions.v3(projectId, client)),
])

// Let page handle 404
if (!project) return
Expand Down
11 changes: 10 additions & 1 deletion apps/frontend/src/plugins/tanstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ export default defineNuxtPlugin((nuxt) => {
const vueQueryState = useState<DehydratedState | null>('vue-query')

const queryClient = new QueryClient({
defaultOptions: { queries: { staleTime: 10000 } },
defaultOptions: {
queries: {
staleTime: 10000,
retry: (failureCount, error) => {
const status = (error as any)?.statusCode ?? (error as any)?.status
if (status !== undefined && status >= 400 && status < 500 && status !== 429) return false
return failureCount < 3
},
},
},
})
const options: VueQueryPluginOptions = { queryClient }

Expand Down
Loading