Next.js App on Firebase Hosting (frameworksBackend) Fails with 404 - nextServer Cloud Run Not Starting

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):

  1. Verified GCP APIs: I have confirmed in the Google Cloud Console that Cloud Build API, Cloud Run API, and Artifact Registry API are all enabled.

  2. Cloud Run Authentication: I have set the nextServer Cloud Run service to “Allow unauthenticated invocations”.

  3. standalone Output: As you can see in my next.config.js, I am using the output: 'standalone' option, which is the recommended practice.

  4. Code Isolation: I have tried deploying a minimal “Hello World” page.tsx with a simplified root layout.tsx (removing all context providers). The deployment still results in a 404.

  5. Configuration Reset: I have tried simplifying package.json to its bare essentials and using the most minimal firebase.json and next.config.js possible. The issue persists.

  6. Logs: The logs in Firebase and Cloud Run are very generic. They show the nextServer instance 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