4
3

More than 5 years have passed since last update.

Vue-CLIのdev serverでoptionの--httpsが効かない時にvue.config.jsを設定

Last updated at Posted at 2019-07-12

vue-cliで立ち上がる開発サーバをhttpsにしたかったのですが、方法が分からずしばらく探し回ったのでメモしておきます。
@dojyorinさんの『vue-cliのdev-serverをhttps化する』に記載されている方法でも解決できるかもしれませんが、また別の方法です。

出てたエラー

vue-cli-service serveのドキュメントに書いてあった npm run serve --httpsが効かなかった。Powershellで以下を実行するとエラーが出てました。

> npm run serve --https
npm WARN invalid config https-proxy=true
npm WARN invalid config Must be a full url with 'http://'

https://qiita.com/ymaru/items/cf513ab05fe0ebac7d3b などを見て、npm config editで設定を変更したり、proxyやhttps-proxy、strict-sslの設定を変更したりしたのですが、上手くいかず。

解決策

vueのフォーラムでの回答に行きつき、以下の対応でhttps化できました。
vue.config.jsを作成して以下を記述。

module.exports = {
  devServer: {
    https: true
  }
}

vue.config.jsはpackage.jsonのあるディレクトリに追加。詳細はvue.config.jsの公式ドキュメントを参照。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3