Enabling HTTPS on express.js

前端 未结 7 925
栀梦
栀梦 2020-11-22 08:44

I\'m trying to get HTTPS working on express.js for node, and I can\'t figure it out.

This is my app.js code.

var express = require(\'exp         


        
7条回答
  •  逝去的感伤
    2020-11-22 09:29

    This is my working code for express 4.0.

    express 4.0 is very different from 3.0 and others.

    4.0 you have /bin/www file, which you are going to add https here.

    "npm start" is standard way you start express 4.0 server.

    readFileSync() function should use __dirname get current directory

    while require() use ./ refer to current directory.

    First you put private.key and public.cert file under /bin folder, It is same folder as WWW file.

提交回复
热议问题