Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1535

"routing-controllers"+"express" does dot provide the access on HTTPS protocol at local development mode

$
0
0

Although I have not found the idiomatic code for Express.js +routing-controllers, rely on this hint on the GitHub discussions, I suppose it will be:

import HTTPS from "https";import Path from "path";import BodyParser from "body-parser";import createExpressApplication from "express";import type { Express as ExpressApplication } from "express";import { useExpressServer as supportClassSyntax } from "routing-controllers";const expressApplication: ExpressApplication = createExpressApplication().    // Use various plugins    use(BodyParser.json());HTTPS.createServer(  {    key: FileSystem.readFileSync(      Path.join(process.cwd(), "ssl" "SSL_Key-FrontServer.LocalDevelopment.pem"), "utf8"    ),    cert: FileSystem.readFileSync(      Path.join(process.cwd(), "ssl", "SSL_Certificate-FrontServer.LocalDevelopment.pem"), "utf8"    )  },  expressApplication);supportClassSyntax(  expressApplication,  {    controllers: [      // ...    ]  }).    listen(      443,      (): void => {        console.log("Server started")      }    );

Please note that I have confirmed that the paths to SSL Certificate and SSL Key are correct because if I intentionally specify the wrong path to SSL Certificate and/or SSL Key, the application will crash with "Error: ENOENT: no such file or directory".

If to try to access "https://localhost:443", it will be the "The site can' provide a secure connection" error at broswer:

enter image description here

However, http://localhost:443/ works.What is wrong? I don't need the http, I need the https.

The function useExpressServer from "routing-controllers" (I have aliased it as supportClassSyntax) return the instance of the Express application which has listen method. No errors should be here.

"How you have obtained the SSL certificate and key?"

By the mkcert utility:

mkcert localhost 127.0.0.1

As far I as have understood, the port number does not matters.


Viewing all articles
Browse latest Browse all 1535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>