I have a certificate issued by AWS for my domain, and as informed I configured it on register.com. Problem is that when I open the site with www.example.com it appears as an invalid certificate, but when I open it directly with https://example.com it appears a valid certificate.
I am using NodeJS as a server, how do I redirect to always open the domain like https://example.com ?
Now is working like this:
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', 'Locale, X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding, Content-Encoding');
res.setHeader('Access-Control-Expose-Headers', 'Locale');
if ((req.headers["x-forwarded-proto"] || "").endsWith("http")) {
res.redirect(`https://${req.headers.host}${req.url}`);
}
next();
});
My certificate