You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to deploy to firebase hosting for NextJS application, show 404 (not found) page #8274
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 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
[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.
[REQUIRED] Actual behavior
Reacted by Felix
Reacted by 0xApplePie
Reacted by Leonardo Ortiz, Chalo Salvador, Felix and Hung
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.
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]
@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?
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
Activity
0xApplePie commentedon Mar 3, 2025
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]ZhuZean commentedon Mar 4, 2025
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 🤔
0xApplePie commentedon Mar 4, 2025
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@latestto either justnpx firebase-toolsornpx [email protected]ZhuZean commentedon Mar 4, 2025
@0xApplePie Thank you!
I figured it out by indicating the
firebaseToolsVersion: "13.31.2"in the deployment file.chalosalvador commentedon Mar 4, 2025
@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]There might be something specific I'm missing. Would you mind confirming you're still experiencing this and share any other relevant details?
chalosalvador commentedon Mar 5, 2025
@ZhuZean, would you mind sharing a cleaned-up version of your firebase.json file?
ZhuZean commentedon Mar 6, 2025
@chalosalvador
Sure, here is my
firebase.jsonfileaalej commentedon Mar 6, 2025
I'm able to reproduce the issue using Flutter. It looks like this occurs when using
siteinstead oftargetin the hosting config of yourfirebase.jsonA config that uses
targetworks. Deploy withfirebase deploy --only hosting:prodfirebase.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 withfirebase deploy --only hosting:aalej-test-sitefirebase.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?
leoortizz commentedon Mar 6, 2025
thanks @aalej, we're working on a fix at the moment
prepare webframeworks only if some is being deployed
leoortizz commentedon Mar 7, 2025
A fix for this issue was implemented in #8295 and will be available in the next firebase-tools release
Fix webframeworks deployments when using `site` in `firebase.json` (#…
trigonometric-act commentedon Mar 12, 2025
Sorry to reopen this, but I still needed to use firebaseToolsVersion: "13.31.2" to be able to deploy
mike-tonakai commentedon Mar 12, 2025
@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
chalosalvador commentedon Mar 12, 2025
@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.jsonand.firebasercfiles?trigonometric-act commentedon Mar 12, 2025
Sure!
firebase.json:
.firebaserc:
chalosalvador commentedon Mar 12, 2025
@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.
firebase/firebase-tools#8274 coba lihat ini