Secure Cookies
Learn how to securely store Crossmint Auth cookies in your application
Authentication tokens are accessible to client-side JavaScript by default through non-HttpOnly cookies. For stronger security, you can store tokens in HttpOnly cookies, which are accessible only on the server side. This setup requires custom routes for refreshing tokens and logging out, using utilities from @crossmint/server-sdk
.
1. Configure Cookie Options
When initializing the server SDK, configure secure cookie options:
Note: The httpOnly
flag only applies to the refresh token. The session JWT remains accessible to client-side JavaScript since it’s needed for API calls.
2. Custom Routes Implementation
Token Refresh Route
Logout Route
3. Client Configuration
Configure the client SDK to use your custom routes:
Note: Depending on the framework you’re using, you might need to set the whole URL in the refreshRoute
and logoutRoute
options.