Hello Firebase Community,
I’m facing a persistent 404 error with my Next.js 14 application deployed on Firebase Hosting using the frameworksBackend feature. The deployment process via the Firebase CLI completes without any errors, but the live site (and the Cloud Run service URL) returns a 404.
The core issue seems to be that the nextServer service on Cloud Run is not starting or running correctly, but I’m not getting any specific application errors in the logs, only the 404 from the Google Cloud infrastructure.
Here are my key configuration files:
firebase.json:
{
"hosting": {
"source": ".",
"frameworksBackend": {
"region": "us-central1"
},
"rewrites": [
{
"source": "**",
"function": "nextServer"
}
]
},
"firestore": {
"rules": "database.rules.json",
"indexes": "firestore.indexes.json"
}
}
next.config.js:
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
reactStrictMode: true,
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'placehold.co',
port: '',
pathname: '/**',
},
],
},
};
module.exports = nextConfig;
Troubleshooting Steps I’ve Already Taken (Without Success):
-
Verified GCP APIs: I have confirmed in the Google Cloud Console that
Cloud Build API,Cloud Run API, andArtifact Registry APIare all enabled. -
Cloud Run Authentication: I have set the
nextServerCloud Run service to “Allow unauthenticated invocations”. -
standaloneOutput: As you can see in mynext.config.js, I am using theoutput: 'standalone'option, which is the recommended practice. -
Code Isolation: I have tried deploying a minimal “Hello World”
page.tsxwith a simplified rootlayout.tsx(removing all context providers). The deployment still results in a 404. -
Configuration Reset: I have tried simplifying
package.jsonto its bare essentials and using the most minimalfirebase.jsonandnext.config.jspossible. The issue persists. -
Logs: The logs in Firebase and Cloud Run are very generic. They show the
nextServerinstance starting due to traffic but then immediately serving a 404, with no specific application-level error message pointing to a crash or a missing module.
Given that even a minimal “Hello World” app fails to deploy correctly under this project, I strongly suspect the issue is not with the application code itself but with some hidden configuration or state within my Firebase/GCP project environment.
Has anyone encountered a similar “unstoppable 404” issue? Is there any other project-level setting or permission I might be missing that could cause the Cloud Run provisioning for nextServer to fail silently?
Any help or insight would be greatly appreciated. Thank you