Skip to content

Conversation

nginx-jack
Copy link
Collaborator

@nginx-jack nginx-jack commented Jan 21, 2025

Add coveo jwt caching.

This change will store the coveo org id and token as a JWT in localstorage.
When the page is bootstrapping, it will check local storage for the token and check if the token is valid.
It will use the token from cache if it's still valid, or make a request for a new one if it has expired.

The goal of this is to stop the persistent reloading of the search input box on page change, and this seems to achieve that 👌 .

Note: Security wise, this JWT is already visible in plain text looking in the network tab. Given coveos strict CORS and short token life, storing this in local storage isn't an issue.

@nginx-jack
Copy link
Collaborator Author

Reached out to security for approval on this approach, will update with response.

@nginx-jack
Copy link
Collaborator Author

Security suggested a HTTPOnly cookie if possible, but that's not possible for our setup without implementing a running backend (or adding a bunch of logic in NJS), so we're good to proceed 👍

@nginx-jack nginx-jack merged commit 5bc7e35 into main Jan 24, 2025
@nginx-jack nginx-jack deleted the coveo-jwt-cache branch July 31, 2025 12:27
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

Successfully merging this pull request may close these issues.

3 participants