I'm building a react app and I'd like to use let's encrypt certificate for webpack-dev-server. Can I use own certificates (.pem
files) and pass it for webpack-dev-server config?
Asked
Active
Viewed 3,701 times
1
-
Do you want to enable https for webpack-dev-server? – svltmccc Dec 20 '19 at 13:22
-
Yes I want to enable it for that. – asiweb Dec 20 '19 at 13:27
-
Welcome to Stack Overflow. It will depend on how you are packaging your app for deployment to production, and whether you will use a load balancer (which typically handles https for you). You need to provide information about your desired target environment for us to help you – Mikkel Dec 20 '19 at 13:28
-
Does this answer your question? [Webpack Dev Server running on HTTPS/Web Sockets Secure](https://stackoverflow.com/questions/26663404/webpack-dev-server-running-on-https-web-sockets-secure) – Mikkel Dec 20 '19 at 13:29
-
At the moment I am using docker for it. I made the image, in the Dockerfile I'll add the certificate files to the project. But after I don't know where to set the paths to those files. So far in the dockerfile I just included the files of the project and run npm start. – asiweb Dec 20 '19 at 13:32
-
For dev configuration you typically use url based on localhost or 127.0.0.1. Let-s-encrypt do not provide certificate for such base. But for domains. (Or provide link where you have read that) – oklas Dec 20 '19 at 13:39
-
@asiweb you can try this https://github.com/webpack/webpack-dev-server/tree/master/examples/cli/https#using-your-certificate – svltmccc Dec 20 '19 at 13:45
1 Answers
0
in the webpack.config.js do the following :
const fs = require('fs');
//...
module.exports = {
//...
devServer: {
https: {
key: fs.readFileSync('/path/to/server.key'),
cert: fs.readFileSync('/path/to/server.crt'),
ca: fs.readFileSync('/path/to/ca.pem'),
},
},
};

Leo wang
- 46
- 3