Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix: query invalidation

varonix09c0639024a5e
diff --git a/frontend/src/hooks/api/auth/queries.tsx b/frontend/src/hooks/api/auth/queries.tsx
index 95e1ab5646..bef629bfe6 100644
--- a/frontend/src/hooks/api/auth/queries.tsx
+++ b/frontend/src/hooks/api/auth/queries.tsx
@@ -32,6 +32,7 @@ import {
VerifyMfaTokenRes,
VerifySignupInviteDTO
} from "./types";
+import { adminQueryKeys } from "../admin";
export const authKeys = {
getAuthToken: ["token"] as const
@@ -103,6 +104,7 @@ export const useSelectOrganization = () => {
queryClient.invalidateQueries({ queryKey: authKeys.getAuthToken });
queryClient.invalidateQueries({ queryKey: organizationKeys.getUserOrganizations });
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserProjects() });
+ queryClient.invalidateQueries({ queryKey: adminQueryKeys.serverConfig() });
}
});
};
diff --git a/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx b/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
index 3020b0ccf0..bcd8a312a3 100644
--- a/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
@@ -73,6 +73,7 @@ import { OrgPermissionSubOrgActions } from "@app/context/OrgPermissionContext/ty
import { isInfisicalCloud } from "@app/helpers/platform";
import { useToggle } from "@app/hooks";
import {
+ adminQueryKeys,
projectKeys,
subOrganizationsQuery,
useGetOrganizations,
@@ -221,10 +222,12 @@ export const Navbar = () => {
}
SecurityClient.setToken(token);
+ queryClient.removeQueries({ queryKey: adminQueryKeys.serverConfig() });
queryClient.removeQueries({ queryKey: authKeys.getAuthToken });
queryClient.removeQueries({ queryKey: subOrgQuery.queryKey });
await queryClient.refetchQueries({ queryKey: authKeys.getAuthToken });
+ await queryClient.refetchQueries({ queryKey: adminQueryKeys.serverConfig() });
await navigateUserToOrg({ navigate, organizationId, navigateTo });
queryClient.removeQueries({ queryKey: projectKeys.allProjectQueries() });
diff --git a/frontend/src/pages/root.tsx b/frontend/src/pages/root.tsx
index 42aea6d8f6..a913c4df22 100644
--- a/frontend/src/pages/root.tsx
+++ b/frontend/src/pages/root.tsx
@@ -5,6 +5,7 @@ import { NotificationContainer } from "@app/components/notifications";
import { TooltipProvider } from "@app/components/v2";
import { adminQueryKeys, fetchServerConfig } from "@app/hooks/api/admin/queries";
import { TServerConfig } from "@app/hooks/api/admin/types";
+import { authKeys, fetchAuthToken } from "@app/hooks/api/auth/queries";
import { queryClient } from "@app/hooks/api/reactQuery";
type TRouterContext = {
@@ -26,6 +27,19 @@ const RootPage = () => {
export const Route = createRootRouteWithContext<TRouterContext>()({
component: RootPage,
beforeLoad: async ({ context }) => {
+ // Seed the in-memory access token from the refresh cookie before any
+ // boot-time API calls, so /admin/config goes out with the Bearer header if present
+ await context.queryClient
+ .fetchQuery({
+ queryKey: authKeys.getAuthToken,
+ queryFn: fetchAuthToken,
+ staleTime: 0
+ })
+ .catch(() => {
+ // No valid refresh cookie — boot continues unauthenticated.
+ // Downstream middlewares handle redirects for protected routes.
+ });
+
const serverConfig = await context.queryClient.ensureQueryData({
queryKey: adminQueryKeys.serverConfig(),
queryFn: fetchServerConfig