I understand to use https with Vue CLI I can set "https: true" under devServer in a vue.config.js file, but I also need a self signed certificate.
I've tried generating a self signed one using OpenSSL and using the following in my vue.config.js file to target:
const fs = require('fs');
module.exports = {
devServer: {
port: '8081',
https: {
key: fs.readFileSync('./certs/server.key'),
cert: fs.readFileSync('./certs/server.cert'),
},
},
};
Chrome confirms it's using my certificate but still shows https as "Not secure"
How can I make chrome assess my self signed certificate as secure when providing it via Vue CLI?
Run Vue. We can change the Vue dev server's config to serve the project over HTTPS rather than HTTP. To do that, we read the private key and certificate. And we set the URL to serve the project on. We read in the files and set them as the properties of the https property.
Open in browser To view the project, open a tab and type http://localhost:3000 into the URL bar. That's the address that the Node server is listening to. You should now see this page, which is the basic structure of our project.
Simply enter this in your Chrome
chrome://flags/#allow-insecure-localhost
Set to Enabled
, restart Chrome, and you're good to go.
My problem was that everybody talks about putting the cert properties in the "https" child configuration node, but this doesn't work, you hve to put it in the devServer config node:
module.exports = {
devServer: {
port: '8081',
https: {
key: fs.readFileSync('./certs/server.key'),
--> this is WRONG
This is the correct way:
module.exports = {
devServer: {
disableHostCheck: true,
port:8080,
host: 'xxxxxx',
https: true,
//key: fs.readFileSync('./certs/xxxxxx.pem'),
//cert: fs.readFileSync('./certs/xxxxxx.pem'),
pfx: fs.readFileSync('./certs/xxxxxx.pfx'),
pfxPassphrase: "xxxxxx",
public: 'https://xxxxxx:9000/',
https: true,
hotOnly: false,
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With