Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Issue with Google Cloud Load Balancer and Firebase Web App Deployment

I'm facing a challenge with deploying a Next.js SSR project on Firebase Hosting after introducing a load balancer, and I’d love to hear your insights or suggestions.

Background: 
I have a Next.js project with server-side rendering (no index.html, as expected with SSR). Initially, I hosted it successfully on Firebase Hosting by rewriting requests to a Cloud Run service. My original firebase.json configuration looked like this:
json

{
  "hosting": {
    "public": "public",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "**",
        "run": {
          "serviceId": "(myserviceid)",
          "region": "europe-west3"
        }
      }
    ]
  }
}


This setup worked perfectly—requests to the Firebase Hosting URL were routed to my Cloud Run service, and the app rendered as expected.

The Problem
Recently, we introduced a load balancer in front of the Cloud Run service for better traffic management, and now we have a load balancer URL (https://<IPADDRESS>/). I updated my firebase.json to route requests to this new URL, as follows:
json

{
  "hosting": {
    "public": "public",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "/_next/static/*",
        "destination": "/_next/static/$1"
      },
      {
        "source": "**",
        "destination": "http://(IPADDRESS)/$1"
      }
    ]
  }
}


Since this change, visiting the Firebase Hosting URL results in a "Page Not Found" error, stating that no index.html was found. I understand this might be because Firebase Hosting expects static files by default, but I’m unsure how to correctly route SSR requests to the load balancer while maintaining Firebase Hosting’s benefits.

What I’m Looking For:
Any insights into why this configuration isn’t working with the load balancer.

Suggestions on how to properly route SSR traffic from Firebase Hosting to a load balancer URL for a Next.js app.

If anyone has successfully set up a similar stack (Next.js SSR + Firebase Hosting + Load Balancer), I’d love to hear about your setup.

Thanks in advance for any help! I’ll keep experimenting and share any solutions I find.
0 4 973