0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Flutter on the Web の開発環境(ローカル)でHTTPS接続する方法

Posted at

flutterのversionをmaster(2023/11/29時点)にする

flutter channel master
flutter upgrade

or

# fvm使っていれば
fvm use master

以下のコミットが含まれていれば実行時のオプションで証明書を指定することが可能になるようです。
https://github.com/flutter/flutter/commit/428bff1ddefce8850348ac75fd50ec947071d985

※おそらくversion3.17.0以降ならstableでも上記の対応が含まれているのでmasterでなくても問題なさそう、現時点(2023/11/29)だとstableが3.16.0なのでまだ入っていない

オプションを指定して実行

flutter run -d chrome --web-tls-cert-path="[Pathを指定]/tls.crt" --web-tls-cert-key-path="[Pathを指定]/tls.key"

できた

スクリーンショット 2023-11-29 15.54.41.png

おまけ

launch.json

VSCodeで実行する場合はlaunch.jsonを使用すると思いますのでそちらの設定方法を念の為記載

"args": [
  "--web-tls-cert-path=[Pathを指定]/tls.crt",
  "--web-tls-cert-key-path=[Pathを指定]/tls.key",
]

domainを指定する方法

証明書設定するなら合わせて必要かと思うので

flutter run -d chrome --web-hostname=sample.com

launch.jsonの場合

"args": [
  "--web-hostname=sample.com",
]
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?