firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Firebase hosting issues with assetlinks.json

Open Kurczaak opened this issue 1 year ago • 3 comments

I am trying to host assetlinks.json file on my Flutter web app using GitHub actions and Firebase hosting. I successfully managed to achieve this in one of my projects. Unfortunately, when I copy-pasted the configuration to my other project, it does not work. I have tried multiple solutions like:

  • Creating assetlinks.json in GitHub actions both in web, and/or build/web folders
  • Deploying web folder with ./well-known/assetlinks.json file
  • Verifying the content of build./well-known/assetlinks.json file before deployment (It's always correct)
  • Adding "dynamicLinks": true in my firebase.json rewrites section
  • Adding "appAssociation": "NONE"/ "appAssociation": "AUTO" in my firebase.json
  • Verifying the content in browser, postman and https://developers.google.com/digital-asset-links/tools/generator. I feel like I've tried every possible solution. What's more concerning is that I literally copied the setup of one project into another. However, this works perfect when I host the app using 'firebase deploy' in my terminal

[REQUIRED] Environment info

firebase-tools: 13.14.2

Platform: macOS

[REQUIRED] Test case

Host a new Flutter Web App using Github actions with the following config:

firebase.json { "hosting": { "public": "build/web", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "headers": [ { "source": "/.well-known/assetlinks.json", "headers": [ { "key": "Content-Type", "value": "application/json" } ] } ], "rewrites": [ { "source": "/.well-known/assetlinks.json", "destination": "/.well-known/assetlinks.json" } ] } }

firebase-hosting-merge.yml `name: Deploy to Firebase Hosting on merge 'on': push: branches: - main permissions: checks: write contents: read jobs: build: name: Build runs-on: ubuntu-latest steps: - name: 📚 Git Checkout uses: actions/checkout@v4 - name: 🐦 Setup Flutter uses: subosito/flutter-action@v2 with: channel: "stable" flutter-version: 3.24.1

  - name: 🛠️ Build the application
    run: flutter build web

  - name: ⬇️ Archive Production Artifact
    uses: actions/upload-artifact@master
    with:
      name: build
      path: build/web

deploy: name: "Deploy" runs-on: ubuntu-latest needs: build steps: - name: 📚 Checkout repo uses: actions/checkout@v4 - name: ⬇️ Download Artifact uses: actions/download-artifact@master with: name: build path: build/web

  - name: 🎯 Deploy to firebase
    uses: FirebaseExtended/action-hosting-deploy@v0
    with:
      repoToken: '${{ secrets.GITHUB_TOKEN }}'
      firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_YOUR_PROJECT }}'
      projectId: your-project-id
      channelId: live`

[REQUIRED] Steps to reproduce

  1. Create a new Flutter app
  2. Create a new Firebase project
  3. Run firebase init and setup Hosting with GitHub actions
  4. Replace the content of firebase-hosting-merge.yml and firebase.json with your data
  5. Add web/.well-known/assetlinks.json file according to the generator https://developers.google.com/digital-asset-links/tools/generator.
  6. Push changes to main branch, running github actions
  7. Visit your-domain.com/.well-known/assetlinks.json

[REQUIRED] Expected behavior

your-domain.com/.well-known/assetlinks.json returns a valid assetlinks.json file

[REQUIRED] Actual behavior

your-domain.com/.well-known/assetlinks.json returns []

Kurczaak avatar Sep 19 '24 04:09 Kurczaak

Hey @Kurczaak - I'm not very familiar with assetlinks.json, but one possible cause here would be that the "**/.*" pattern in firebase.json#hosting.ignore is causing .well-know/assetlink.json to be ignored. If you remove that pattern (or move assetlink.json to another folder that doesn't begin with .), does it work as expected?

joehan avatar Sep 24 '24 17:09 joehan

The file needs to be in "./well-known" directory so I deleted the "**/.*" pattern in firebase.json#hosting.ignore. Unfortunately, it didn't solve the problem

Kurczaak avatar Sep 24 '24 18:09 Kurczaak

@Kurczaak Have you ever found a solution to this issue ?

ready4sea avatar Jun 11 '25 08:06 ready4sea

This a very problem, is impossible to migrate DyanamicLink firebase :-( Because is impossible to update file in my projet flutter -> web/.well-known/assertlink.json

Lerobindesbois avatar Aug 23 '25 15:08 Lerobindesbois