Skip to content

Instantly share code, notes, and snippets.

@luizamboni
Created May 26, 2020 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luizamboni/14e46615ba126dc0a3ee4a65460ec017 to your computer and use it in GitHub Desktop.
Save luizamboni/14e46615ba126dc0a3ee4a65460ec017 to your computer and use it in GitHub Desktop.
how add config by env vars in next.js
<script>
const configValues = document.cookie.split('; ').find(c => c.startsWith('config')).split('=')[1]
const config = JSON.parse(window.unescape(config))
</scrip>
module.exports = (req, res, next) => {
res.cookie("config", JSON.stringify({ endpoint: process.env.END_POINT || "https://localhost:3000" }));
next();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment