how to run webpack server in both http and https

Viewed 31

i created a dummy private and public key file key.pem and cert.perm and added that to webpack.dev.js

and this is my webpack.dev.js

const fs = require("fs");
const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
const path = require("path");

module.exports = merge(common, {
  mode: "development",
  devtool: "eval-source-map",
  devServer: {
    static: {
      directory: path.join(__dirname, "../../dist/client"),
    },
    https: {
      key: fs.readFileSync(path.join(__dirname, "../../keys/key.pem")),
      cert: fs.readFileSync(path.join(__dirname, "../../keys/cert.pem")),
    },
    hot: true,
  },
});

this is my package.json scripts object

"scripts": {
    "dev": "webpack server --config ./src/client/webpack.dev.js",
},

my issue here is that when i do npm run dev it run the webpack server https://localhost:8080 and it works whereas http://localhost:8080 does not work.

I want my server to run both http and https localhost:8080

how can i do that? Any help please

0 Answers
Related