Skip to content

Commit

Permalink
fix(next-app-router): do not retrieve headers in csr (#6228)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhayab authored Jun 5, 2024
1 parent cd6a150 commit 4fca256
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/react-instantsearch-nextjs/src/InstantSearchNext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export function InstantSearchNext<
};
}, []);

const nonce = safelyRunOnBrowser(() => undefined, {
fallback: () => headers().get('x-nonce') || undefined,
});

const routing = useInstantSearchRouting(passedRouting, isMounting);

const promiseRef = useRef<PromiseWithState<void> | null>(null);
Expand All @@ -73,9 +77,7 @@ This message will only be displayed in development mode.`
<InstantSearchRSCContext.Provider value={promiseRef}>
<InstantSearchSSRProvider initialResults={initialResults}>
<InstantSearch {...instantSearchProps} routing={routing}>
{!initialResults && (
<InitializePromise nonce={headers().get('x-nonce') || undefined} />
)}
{!initialResults && <InitializePromise nonce={nonce} />}
{children}
{!initialResults && <TriggerSearch />}
</InstantSearch>
Expand Down

0 comments on commit 4fca256

Please sign in to comment.