Pass sensitive data from loader to client #13119
Unanswered
brendanfmartin
asked this question in
Q&A
Replies: 1 comment 9 replies
-
There's no way yo send data from the server to the client without allowing clients to read it. Even if you stopped using the route loader and fetched it, the data is available on the Network tab of the browser devtools. The only safe thing to do is to fetch the API server-side using that sensitive data and return to the client the non-sensitive data needed to render the UI. |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
Some data may be passed from the loader function to the client side. An example is data needed to make authenticated client side API calls. I would like to store this data in memory and remove the data from the DOM.
Example
https://github.com/brendanfmartin/test-react-router-secrets
Start the application. Open the Inspect Elements tab and search for the secret:
ishouldbehidden
You will see the secret value on the
window.__reactRouterContext.streamController
.How do I prevent this value from being shown on the DOM?
Beta Was this translation helpful? Give feedback.
All reactions