我想制作https express服务器,我已经遇到了问题。服务器运行没有错误。对服务器的所有http请求都被路由到https,所以它也没问题。但是我有以下问题:
Access to localhost was denied You don't have authorization to view this page. HTTP ERROR 403
https.createServer( options, app ).listen( 443 );
所以我致电https://localhost,我得到同样的错误Access to localhost was denied You don't have authorization to view this page. HTTP ERROR 403
我的服务器代码:
const https = require( "https" ),
fs = require( "fs" ),
express = require( 'express' );
var key = fs.readFileSync( 'config/server.key' );
var cert = fs.readFileSync( 'config/server.crt' );
var ca = fs.readFileSync( 'config/server.crt' )
var options = {
key: key,
cert: cert,
ca: ca
};
const app = express();
app.get( '/hello', ( req, res ) => {
res.send( "Hello" )
} )
app.get( '/', ( req, res ) => {
res.send( "home" )
} )
app.listen( 80 );
https.createServer( options, app ).listen( 8080 );