1

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

Pravin Poudel
  • 1,433
  • 3
  • 16
  • 38
  • Did you manage to solve this question? Was the presented config working correctly for https? – nabroyan Jul 08 '23 at 11:35
  • i dont remember but i believe that config is for what the problem is saying. I remember disabling it and enabling it when i needed https !! – Pravin Poudel Jul 09 '23 at 18:56
  • oh yeah, yes, it works for https – Pravin Poudel Jul 09 '23 at 18:56
  • Cool! Another question, which may sounds dummy: the certificates that you provided in the config are the same ones that you have in your backend? Do you need to specify them both in frontent and backend? Or in just one of them is enough? – nabroyan Jul 09 '23 at 21:26
  • if you check the webpack configutation that i have in the post, i am using webpack dev server and since webpack is my server here, i am putting this in webpack configutation. If you are asking about real server, i don't know about that. I am not that familiar with backend to that level. Adding certificate is a backend thing rather than front end but since i am using webpack dev server, my backend is this only. This was more of a front end project. – Pravin Poudel Jul 10 '23 at 16:45

0 Answers0