Reputation: 107
I have a node.js server and a package.json file. In that file I set some variables. For exemple "version" : 3.0. I can access those variables very easily in the node.js server. (Is there a way to get version from package.json in nodejs code?)
var pjson = require('./package.json');
console.log(pjson.version);`
But how can I pass it to my js app working on the frontend? Can I create a constant.js file that is created went I start the server (only ones).
I do not want to pass the variable as an argument every time I render a page.
I use the ejs to render my pages.
Thank you for your help.
Upvotes: 2
Views: 453
Reputation: 1117
You could set a cookie in the initial response.
response.setHeader("Set-Cookie", ["version=3.0"])
Upvotes: 1