簡體   English   中英

如何使用包“ express-https-redirect”從express返回index.html文件

[英]How do I return an index.html file from express using the package 'express-https-redirect'

我有以下默認使用HTTPS的代碼,只是不清楚如何將index.html文件發送回

var express = require('express'),
path = require('path'),
fs = require('fs'),
app = express(),
staticRoot = __dirname + '/',
httpsRedirect = require('express-https-redirect');

app.set('port', (process.env.PORT || 3001));

app.use('/', httpsRedirect())

app.listen(app.get('port'), function () {
    console.log('app running on port', app.get('port'));
});

任何幫助是極大的贊賞

您通常可以按照以下方式發送html 文件

app.get('/', function(req, res) {
   res.sendFile(path.join(__dirname + '/index.html'));
});

注意: express-https-redirect中間件將非安全訪問重定向到“僅HTTPS”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM