After node sets up the https server, the browser request reports an error, but the postman request has no problem.

The

web page is https, but the node service of the backend or http has not been upgraded, so the ip port browser requesting http at the front end will report an error.

then follow the steps to upgrade the node service to https

https://itnext.io/node-expres.
node code is fine. Start and run ok

const express = require("express");
const app = express();
const https = require("https")
const http = require("http")
const fs = require("fs")
const bodyParser = require("body-parser")
const jwt= require("jsonwebtoken");
const expressJwt = require("express-jwt");


//
const privateKey = fs.readFileSync("/etc/letsencrypt/live/xxxx.xxx/privkey.pem", "utf8");
const certificate = fs.readFileSync("/etc/letsencrypt/live/xxxx.xxx/cert.pem", "utf8");
const ca = fs.readFileSync("/etc/letsencrypt/live/xxxx.xxx/chain.pem", "utf8");

const credentials = {
    key: privateKey,
    cert: certificate,
    ca: ca
};
var httpServer = http.createServer(app);
var httpsServer = https.createServer(credentials, app);
 
//httphttps
var PORT = 3001;
var SSLPORT = 3002;
 
//http
httpServer.listen(PORT, function() {
    console.log("HTTP Server is running on: http://localhost:%s", PORT);
});
 
//https
httpsServer.listen(SSLPORT, function() {
    console.log("HTTPS Server is running on: https://localhost:%s", SSLPORT);
});

but the front end is changed to https://172.XXX.XXX.XXX:3002 browser will report an error, but there is no problem with postman

clipboard.png

clipboard.png

iphttps://www.xxx.com:3002

chromesecurity

clipboard.png


because you generate the domain name specified in the https instead of the IP address, the browser has a process of verifying the certificate.


the certificate is signed with a domain name


https certificate corresponds to domain name, not ip

clipboard.png

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9b845-47620.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9b845-47620.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?