Created
November 5, 2022 18:14
-
-
Save alberto-marin/d2514c28f585414fe046d179c03b046a to your computer and use it in GitHub Desktop.
Example sensitive data in props
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function Home(props) { | |
// Now you can see your secret key just by using the React Developer Tools for Firefox/Chrome | |
[...] | |
} | |
export async function getServerSideProps() { | |
// call API to get the secret key | |
const options = { | |
method: 'GET', | |
headers: { | |
'Authorization': process.env.BEARER | |
} | |
}; | |
const res = await fetch(process.env.NEXT_PUBLIC_API_SERVER, options) | |
.then(response => response.json()); // We get the secret key | |
// Don't do this! | |
return { | |
props: { res } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment