Tuesday 30 May 2017

how to access http => https with nodes, React.js

I have running server nodeJs with express module. And website is made by React.js which is server-side-redering.

And I have domain : www.example.com, Route53 with load balancer applied AWS Certificate Manager.

the problem is I don't know how to automatically access https:// protocol, when I type url http://www.example.com

now, I can access each of url like as http://www.example.com or https://www.example.com

I found solution :

app.use (function (enter code herereq, res, next) {
    if (req.secure) {
        next();
    } else {
        res.redirect('https://' + req.headers.host + req.url);
    }
});

but it's not working...

what is nice way???



via XOneto9

No comments:

Post a Comment