firebase / firebase/firebase-tools

Firebase hosting issues with assetlinks.json

Open
#7,685 6 comments 0 reactions 0 assignees View on GitHub
api: hosting type: bug
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

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](https://github.com/Kurczaak/deeplinker). 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 `[]`

Contributor guide

Open the contributing guide

Research direction

Start with firebase.json and firebase-hosting-merge.yml, then reproduce the deployment using the listed Flutter web build and FirebaseExtended/action-hosting-deploy workflow. Compare the deployed /.well-known/assetlinks.json with the generated file and trace why the workflow returns [] instead of the valid assetlinks.json content.

Written by the indexing model from the issue text.

Assessment

Tech stack
flutter, github-actions
Domain
ci-cd, cloud, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.