To get the full app experience, you’ll need to log in.
How to configure SSL certificate with Express.JS for an HTTPS server
1. Initialize your NodeJS project and generate the package.json file.
npm init
2. Install Express.JS
npm install express
3. Download the certificate and private key pair for your RedirectTo.Me domain.
4. Configure Express to use your certificate.
const https = require('node:https');
const fs = require('node:fs');
// Import the express module
const express = require("express");
// Instantiate an Express application
const app = express();
https
.createServer(
// Provide the private key and certificate to the server by reading each
// file's content with the readFileSync() method.
{
key: fs.readFileSync("key.pem"),
cert: fs.readFileSync("cert.pem"),
},
app
)
.listen(8001, () => {
console.log("Server is runing at port 8001");
});
app.get('/', (req,res)=>{
res.send("Hello from express server.")
})
5. Start your HTTPS server
node index.js
5. Visit your domain + port combo via
e.g.
https
in your browser.e.g.
https://magic-moment-1234.redirectto.me:8001