LoginSignup
15
15

More than 5 years have passed since last update.

自己証明でhttpsしてservice workerを動かすときのchromeのオプション

Posted at

TL;DR

別プロセスで起動する。

問題

service workerはhttp上では動きません。
ただローカルでもservice worker動かしたいし、どっかサービス使うより、自己証明でちゃちゃっとhttps環境用意したい。
でも、それはうまくいきません。

理由

chromeはオレオレ証明書を使ったhttps通信上だと、service workerを使うときに、以下のようなエラーを出します。

DOMException: Failed to register a ServiceWorker: An SSL certificate error occurred when fetching the script.

安全じゃないからダメってことですね。
いいことだと思います。

対応

そんなときは、chrome起動時に、以下のようにオプションをつければいいようです。

google-chrome --ignore-certificate-errors --unsafely-treat-insecure-origin-as-secure=https://your-application-path --allow-insecure-localhost --user-data-dir=/any/path

この時、新しい設定を作って動かすので、普通に起動した時の設定は引き継がれないようです。
オプションに指定したディレクトリに新しく設定を入れるようです。

まとめ

service workerを使いましょう。

15
15
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
15
15