Issue with custom domains on Google App Engine

I have a NextJS app that I am trying to migrate from Google App Engine to Cloud Run. However, when I try logging in with Google Cloud Run I get the error:

Callback handler failed. CAUSE: Missing state cookie from login request (check login URL, callback URL and cookie config).

The problem (I think) is I have a custom domain configured with Firebase hosting (see here) sitting in front of my Cloud Run service. This probably means that the cookie is signed from Domain A (The front-facing domain), but gets sent to the backend Domain B (The default domain). I’m not sure how I would go about solving this problem. Has anyone faced this issue before?