[Vuejs]-Access to api with certificate on localhost (vue.js app)

0👍

Because you should generate your own cert and provide keys in config.

module.exports = {
  devServer: {
    https: {
      cacert: './server.pem',
      pfx: './server.pfx',
      key: './server.key',
      cert: './server.crt',
      passphrase: 'webpack-dev-server',
      requestCert: true,
    },
  },
}; 

Also, you can try to set https for automatic ssl generating.

devServer: {
    https: true,
  }

Webpack Version above v4.4.0+

In new webpack version https option was deprecated, you need to specify devServer.server.options to use own certificates:

module.exports = {
  //...
  devServer: {
    server: {
      type: 'https',
      options: {
        ca: './path/to/server.pem',
        pfx: './path/to/server.pfx',
        key: './path/to/server.key',
        cert: './path/to/server.crt',
        passphrase: 'webpack-dev-server',
        requestCert: true,
      },
    },
  },
};

Leave a comment