With Express.js, I'am sending a html file containing a React component within.
app.get('/index', function(req, res) {
res.sendFile(path.join(__dirname + '/src/index.html'));
});
For the purposes, let's assume I want to send a unique variable with my html file to every user connecting to localhost:80/index.
How can I send the vatiable from the server-side and how can I retrieve it from the client side ?
You have several options here.
/api/enviroment
, or something, and make this request as soon as you can. This has the advantage of being able to specify more client side information in your requestdocument.cookie
is your friend)There are some other methods, but I think that these are the best
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments