Skip to content

Unable to deploy to firebase hosting for NextJS application, show 404 (not found) page #8274

Description

@ZhuZean

[REQUIRED] Environment info

firebase-tools: 13.32.0

Platform: Ubuntu

[REQUIRED] Test case

I've built a website with Next js 13.5.4, and using Github Action to deploy the application whenever making a PR or deploying to the staging and production.

I'm using the FirebaseExtended/action-hosting-deploy@v0 for Github Action deployment.

I found Firebase shows a 404 page after I triggered the deployment 2 days ago after the firebase-tools published the latest version (13.32.0).

After digging into the problem, I found the deployment time was much shorter than before after the lastest version was published. It cost around 7 minutes to deploy the firebase preview channel but now it only takes 33 seconds.

404 page from firebase hosting

Image

[REQUIRED] Steps to reproduce

Example of the Github action file

# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: PR - Deploy to Firebase Hosting on PR
'on': pull_request
env:
  WEB_APPLICATION_ENV: development
jobs:
  build_and_preview:
    if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - run: npm ci && npm run build:dev
      - uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: '${{ secrets.GITHUB_TOKEN }}'
          firebaseServiceAccount: '${{ secrets.ABC }}'
          projectId: 123
          target: 123
        env:
          FIREBASE_CLI_EXPERIMENTS: webframeworks

[REQUIRED] Expected behavior

We can deploy the project to the firebase hosting.
Image

[REQUIRED] Actual behavior

Image

Activity

  1. 0xApplePie commented on Mar 3, 2025

    @0xApplePie

    We face the same issue, although we use NextJS 14.
    Our Pipelines for deployment do not work anymore.
    We had no deployment issues for months and did not change any deployment-related code.

    for now use the old version:
    npm i -g [email protected]

  2. ZhuZean commented on Mar 4, 2025

    @ZhuZean
    Author

    Hey @0xApplePie , do you use GitHub Action for deployment?

    It keeps pulling the latest version of the Firebase tool during the Github Action deployment, although I installed the previous before 🤔

    Image
  3. 0xApplePie commented on Mar 4, 2025

    @0xApplePie

    I am not familiar with Github Actions, we use Gitlab CI/CD. But it should work similarly, I think.

    But it looks like you require, in the npx command, the latest version of firebase-tools.
    Maybe change npx firebase-tools@latest to either just npx firebase-tools or npx [email protected]

  4. ZhuZean commented on Mar 4, 2025

    @ZhuZean
    Author

    @0xApplePie Thank you!

    I figured it out by indicating the firebaseToolsVersion: "13.31.2" in the deployment file.

    Image
  5. chalosalvador commented on Mar 4, 2025

    @chalosalvador
    Member

    @ZhuZean Thanks for reporting this. Are you still experiencing the issue?
    I have tried to reproduce it but the action is deploying the preview successfully.
    You can see a minimal reproducible example repo here: chalosalvador/nextjs-deploy#1

    It uses the following Github action that looks like the one you are using with [email protected]

    # This file was auto-generated by the Firebase CLI
    # https://github.com/firebase/firebase-tools
    
    name: PR - Deploy to Firebase Hosting on PR
    'on': pull_request
    permissions:
      checks: write
      contents: read
      pull-requests: write
    env:
      WEB_APPLICATION_ENV: development
    jobs:
      build_and_preview:
        if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v3
          - run: npm ci && npm run build
          - uses: FirebaseExtended/action-hosting-deploy@v0
            with:
              repoToken: ${{ secrets.GITHUB_TOKEN }}
              firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_FB_TOOLS_DEV }}
              projectId: xx-yy-zz
              target: xx-yy-zz
            env:
              FIREBASE_CLI_EXPERIMENTS: webframeworks
    

    There might be something specific I'm missing. Would you mind confirming you're still experiencing this and share any other relevant details?

  6. chalosalvador commented on Mar 5, 2025

    @chalosalvador
    Member

    @ZhuZean, would you mind sharing a cleaned-up version of your firebase.json file?

  7. ZhuZean commented on Mar 6, 2025

    @ZhuZean
    Author

    @chalosalvador

    Sure, here is my firebase.json file

    {
      "hosting": [
        {
          "source": ".",
          "site": "STAGING_PROJECT_ID",
          "ignore": [
            "firebase.json",
            "**/.*",
            "**/node_modules/**"
          ],
          "frameworksBackend": {
            "region": "asia-east1"
          }
        },
        {
          "source": ".",
          "site": "PROD_PROJECT_ID",
          "ignore": [
            "firebase.json",
            "**/.*",
            "**/node_modules/**"
          ],
          "frameworksBackend": {
            "region": "asia-east1"
          }
        }
      ]
    }
    
    
  8. aalej commented on Mar 6, 2025

    @aalej
    Contributor

    I'm able to reproduce the issue using Flutter. It looks like this occurs when using site instead of target in the hosting config of your firebase.json

    A config that uses target works. Deploy with firebase deploy --only hosting:prod

    firebase.json
    {
      "hosting": [
        {
          "target": "prod",
          "source": ".",
          "ignore": ["firebase.json", "**/.!(env)", "**/node_modules/**"],
          "frameworksBackend": {
            "region": "us-central1"
          }
        }
      ]
    }
    .firebaserc
    {
      "projects": {},
      "targets": {
        "<PROJECT_ID>": {
          "hosting": {
            "prod": [
              "aalej-test-site"
            ]
          }
        }
      },
      "etags": {}
    }

    But when switching to site, the issue occurs. Deploy with firebase deploy --only hosting:aalej-test-site

    firebase.json
    {
      "hosting": [
        {
          "site": "aalej-test-site",
          "source": ".",
          "ignore": ["firebase.json", "**/.!(env)", "**/node_modules/**"],
          "frameworksBackend": {
            "region": "us-central1"
          }
        }
      ]
    }

    @chalosalvador could you give this mcve a try to see if you'd be able to reproduce the issue?

  9. leoortizz commented on Mar 6, 2025

    @leoortizz
    Member

    I'm able to reproduce the issue using Flutter. It looks like this occurs when using site instead of target in the hosting config of your firebase.json

    A config that uses target works. Deploy with firebase deploy --only hosting:prod

    firebase.json
    .firebaserc
    But when switching to site, the issue occurs. Deploy with firebase deploy --only hosting:aalej-test-site

    firebase.json
    {
    "hosting": [
    {
    "site": "aalej-test-site",
    "source": ".",
    "ignore": ["firebase.json", "/.!(env)", "/node_modules/**"],
    "frameworksBackend": {
    "region": "us-central1"
    }
    }
    ]
    }
    @chalosalvador could you give this mcve a try to see if you'd be able to reproduce the issue?

    thanks @aalej, we're working on a fix at the moment

  10. added a commit that references this issue on Mar 6, 2025
    148f7e4
  11. self-assigned this
    on Mar 6, 2025
  12. leoortizz commented on Mar 7, 2025

    @leoortizz
    Member

    A fix for this issue was implemented in #8295 and will be available in the next firebase-tools release

  13. added a commit that references this issue on Mar 7, 2025
    34674ac
  14. trigonometric-act commented on Mar 12, 2025

    @trigonometric-act

    Sorry to reopen this, but I still needed to use firebaseToolsVersion: "13.31.2" to be able to deploy

  15. mike-tonakai commented on Mar 12, 2025

    @mike-tonakai

    @leoortizz
    There might be another bug occurring in #8295. Since the change makes use of array.find instead of array.some when config is an array, isDeployingWebFramework will incorrectly be false for the second and subsequent sites in the array.
    https://github.com/firebase/firebase-tools/pull/8295/files#diff-83700cc689349de83ec82d97d011a8365075e5d57513bf0f1283fd3baad57904R52

  16. chalosalvador commented on Mar 12, 2025

    @chalosalvador
    Member

    @trigonometric-act [email protected] has been released and includes this fix. Can you confirm you're experiencing this issue deploying with 13.34.0?

    Do you mind sharing your firebase.json and .firebaserc files?

  17. trigonometric-act commented on Mar 12, 2025

    @trigonometric-act

    Sure!
    firebase.json:

    {
      "hosting": [
        {
          "target": "dev",
          "source": ".",
          "ignore": [
            "firebase.json",
            "**/.*",
            "**/node_modules/**"
          ],
          "frameworksBackend": {
            "region": "europe-west1"
          }
        },
        {
          "target": "prod",
          "source": ".",
          "ignore": [
            "firebase.json",
            "**/.*",
            "**/node_modules/**"
          ],
          "frameworksBackend": {
            "region": "europe-west1"
          }
        },
        {
          "target": "stage",
          "source": ".",
          "ignore": [
            "firebase.json",
            "**/.*",
            "**/node_modules/**"
          ],
          "frameworksBackend": {
            "region": "europe-west1"
          }
        }
      ],
      "functions": {
        "source": "../dir/functions"
      },
      "emulators": {
        "auth": {
          "port": xxx
        },
        "functions": {
          "port": xxx
        },
        "firestore": {
          "host": "127.0.0.1",
          "port": xxx
        },
        "hosting": {
          "port": xxx
        },
        "ui": {
          "enabled": true
        },
        "singleProjectMode": true
      },
      "storage": {
        "rules": "storage.rules"
      },
      "firestore": {
        "rules": "firestore.rules",
        "indexes": "firestore.indexes.json"
      }
    }

    .firebaserc:

    {
      "projects": {
        "default": "dev",
        "prod": "prod"
      },
      "targets": {
        "prod": {
          "hosting": {
            "stage": [
              "stage-site"
            ],
            "prod": [
              "prod-site"
            ]
          }
        },
        "dev": {
          "hosting": {
            "dev": [
              "dev-site"
            ]
          }
        }
      },
      "etags": {}
    }
  18. chalosalvador commented on Mar 12, 2025

    @chalosalvador
    Member

    @trigonometric-act @mike-tonakai Thanks for reporting this. A fix has been pushed via #8314 and will be available in the release of firebase-tools.

  19. added a commit that references this issue on Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions