1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

FlutterFlow (FlutterWeb)でAPI Callが動かない時の対処法

Last updated at Posted at 2024-05-26

FlutterFlowでAPIコールが動作しない問題への対処法

image.png

まず、この不具合はFlutterFlowに依存する問題ではないことあらかじめをお伝えしておきます。

問題

以下のような現象が出ている方に有効かもしれません。

・Runモードやモバイルアプリでビルドしたものでは動いているのに、ローカルでビルドした後に、FirebaseでHostingしたら動かなくなってしまった。

・FlutterFlowでWeb Publishをした後に動かなくなった。

・ビルドしたアプリの内容をWebで公開したらバグや挙動が違うといったことが起きた。

原因

ブラウザ検証モードを使ってログを確認したところ、CORS ERRORというのが確認されました。

以下のような感じでログが出ました。
image.png
CORSについてはこちらを参照: https://qiita.com/koji4104/items/65bba670f0519a23b9f6

簡単に説明すると、今開いているサイトから別のIPアドレス上に存在するAPIをコールするときに、ブラウザ側で自動的にセキュリティのブロックがかかってしまい、そのあとの処理が止まってしまうといったイメージです。

解消手順

1.APIコールのAdvanced Settingsを開き、Make PrivateをONにする。

image.png

2.Deploy Private APIsをONにして、Cloud Function上にAPIコールの関数をデプロイする。

image.png

3.FlutterFlow経由でWebにPublishする

スクリーンショット 2024-05-26 180956.png

上記の手順で解消されました。

※FirebaseHostingを使って、手動でホスティングを行うパターンも試しましたが、こちらでは問題が解消されなかったため、急ぎであればFlutterFlow経由の公開をお勧めします。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?