Next.js Discord

Discord Forum

Prevent queryParams in __NEXT_DATA__ for CDN caching

Unanswered
Scottish Fold posted this in #help-forum
Open in Discord
Scottish FoldOP
Hi all. I'm looking for some advice on preventing potentially sensitive data in url query params from being cached. We are using CloudFront and have some urls that work like this:

https://example.com/mypage?email=user123@example.com

The server response includes NEXT_DATA and contains the user123@example.com email address in the query. If the page is cached like this, other users will be able to see this in their response. Is there a way to prevent this data from being included in the server response?

We have our component code setup to only use the email query param on the client-side, but I can't find a way to prevent the server response from including the query params in the NEXT_DATA.

Does anyone have any suggestions for allowing CDN cache, but without this data being included in the response?

0 Replies