Steve
Steve

Reputation: 732

Heroku https://www redirect to https://

I want http://example.com, http://www.example.com and https://www.example.com redirect to https://example.com.

To achieve so I have the following Namecheap dns records:

CNAME @ example.com.herokudns.com   
URL REDIRECT RECORD www http://example.com

I'm also using heroku-ssl-redirect to redirect from http:// to https://

var sslRedirect = require('heroku-ssl-redirect');
var express = require('express');
var app = express();

// enable ssl redirect
app.use(sslRedirect());

What I get is that everything works as I expected besides https://www, it doesn't even load an app. How can I make https://www work and redirect to https://non-www as I described above?

Upvotes: 3

Views: 355

Answers (1)

John Beynon
John Beynon

Reputation: 37507

You can't do the redirect at the DNS level for the www record, you'd need to redirect at the app. The reason is that if the redirect is at your DNS provider then the client browser will connect to https www.site.com but your DNS provider will not have a valid cert for your domain and the request will be refused by your browser, assuming of course that your DNS provider has port 443 open - which they sound like they don't.

Upvotes: 2

Related Questions