New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to force all requests to https? #764
Comments
Assuming you have https and http both set up already and running in the same node app, it's as easy as adding: app.use(function(req, res, next) {
if(!req.secure) {
return res.redirect('https://your-site-name-here');
}
next();
}); Of course, you could split this into a redirect module, put it after certain endpoints that don't need to be secure, whatever you want to do. |
Great explanation @andrewstuart 👍 @softBarbarian you should be able to use: |
Thanks for your help @kingcody and @andrewstuart Here are my results: can you please point me to right direction? |
So if
but
where does:
redirect to? |
Redirects to https |
To a 404? I'm only asking because you said that going to https:// manually gives you a 404. So does the redirect to https:// 404 as well? |
Only one of the https requests gives 404 1 the one without www. So https://www.mysite.com - works |
I wonder if this is registrar/openshift level issue? |
softBarbarian, You might have checked these but check the basics. confirm DNS points to the same server: With a browser pointed to https://www.mysite.com do you see your SSL cert? You can also do each of: try each of: Are you on a shared (virtual) host? What are you using/doing to support SSL? |
Did not have much time to go thru your steps @jeffbuhrt will do it tomorrow.
This is set up accordingly to OpenShift tutorial. @kjellski, do you think CNAME entry might be a problem? |
just add this code in your .htaccess file you can easily redirect your page into secure page try its work for me |
great detailed solutions. Thanks |
Hello I would like to mention that this is awesome generator I love it.
I have a quick question.
How would one force all http requests to https? I tried to add some rules to .haccess file but that does not seem to work.
I am running the site on openshift bronze plan.
Thanks a lot,
Happy New Year!
The text was updated successfully, but these errors were encountered: