我如何从http重定向到https express.js

时间:2020-06-24 04:32:41

标签: reactjs express http https

我正在直接服务React build。因此,请考虑一下以解决您的问题。

import express from "express";

let port = process.env.PORT || 8000;

const app = express();
app.use(cors());
app.use(express.json());

...
// // All start from index.html
app.get("/*", (req, res) => {
  res.sendFile(path.resolve("index.html"));
});

app.listen(port, () => {
  console.log("server is online: " + port);
});

0 个答案:

没有答案
相关问题