I do not really have a big experience in production mode of nodejs & reactjs, and today i heard that i should do force ssl. i did some googling and as it seems
function requireHTTPS(req, res, next) {
if (!req.secure && req.get('x-forwarded-proto') !== 'https' && process.env.NODE_ENV !== "development") {
return res.redirect('https://' + req.get('host') + req.url);
}
next();
}
app.use(requireHTTPS);
this kind of code is used for expressjs to force ssl. (code from lavamantis)
then i did some researches about forcing ssl with reactjs, because using res.redirect
with react is not thing that i heard before. and as it seems i should do following in package.json
"scripts": {
"start": "set HTTPS=true&&react-scripts start",
...
}
so what should i do when i am using reactjs with nodejs? i have not deployed single application of their combination but when i will i think i will use nginx