Skip to content

Query client integration leaks information between requests #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Benjamin-Lee opened this issue May 21, 2025 · 0 comments
Open

Query client integration leaks information between requests #108

Benjamin-Lee opened this issue May 21, 2025 · 0 comments

Comments

@Benjamin-Lee
Copy link

Which project does this relate to?

Create Tanstack App

Describe the bug

When using the default configuration of TanStack Query, state is injected into all requests, even if they came from a different user. This could leak information and should not the default.

Your Example Website or App

https://github.com/Benjamin-Lee/tanstack-start-query

Steps to Reproduce the Bug or Issue

  1. Create a new TanStack Start project with the Query integration active
  2. Load the demo route for Query: http://localhost:3000/demo/tanstack-query
  3. Go to another page and reload: the server side context is injected back into page

Expected behavior

There should be no server side state injected into different requests. This could be a security issue if an authenticated client runs a query which is cached on the server, which then uses that cache to inject the state for a different user.

To get the expected behavior, I have made this my router.tsx:

// Create a new router instance
export const createRouter = () => {
  const queryClient = new QueryClient()
  const router = routerWithQueryClient(
    createTanstackRouter({
      routeTree,
      context: {
        queryClient,
      },
      scrollRestoration: true,
      defaultPreloadStaleTime: 0,
      defaultPreload: "intent",
    }),
    queryClient
  )

  return router
}

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: all
  • Version: 0.15.3

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant