Skip to content

Instantly share code, notes, and snippets.

@alberto-marin
Created November 5, 2022 18:14
Show Gist options
  • Save alberto-marin/d2514c28f585414fe046d179c03b046a to your computer and use it in GitHub Desktop.
Save alberto-marin/d2514c28f585414fe046d179c03b046a to your computer and use it in GitHub Desktop.
Example sensitive data in props
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