Service to service request in App Engine with IAP

275 views
Skip to first unread message

Matthew Bise

unread,
May 27, 2021, 4:27:42 AM5/27/21
to Google App Engine

I'm using Google App Engine to host a couple of services (a NextJS SSR service and a backend API built on Express). I've setup my dispatch.yaml file to route /api/* requests to my API service and all other requests get routed to the default (NextJS) service

Dispatch.yaml:
dispatch: 
   - url: '*/api/*' service: api

The problem: I've also turned on Identity-Aware Proxy for App Engine. When I try to make a GET request from my NextJS service to my API (server-side, via getServerSideProps) it triggers the IAP sign-in page again instead of hitting my API. I've tried out a few ideas to resolve this:

  1. Forwarding all cookies in the API request
  2. Setting the X-Requested-With header as mentioned here
  3. Giving IAP-secured Web App User permissions to my App Engine default service account

But nothing seems to work. I've confirmed that turning off IAP for App Engine allows everything to function as expected. Any requests to the API from the frontend also work as expected. Is there a solution I'm missing or a workaround for this?

Damian Plaza Moral

unread,
May 28, 2021, 8:21:42 AM5/28/21
to Google App Engine
Hello,

I see in this link there is an identical post in Stack Overflow, with a good answer, I share it here if anyone else is facing the same issue.

Regards.

Reply all
Reply to author
Forward
0 new messages