1
votes

The setup:

  • Service A (frontend): GAE serving static site, all calls made from A are happening on client side.
  • Service B (api): GAE instance hosting REST API.

Without Identity Aware Proxy, I am able to make requests from the clientside of the frontend to the api on a different hostname by setting CORS to allow calls from the service A hostname.

I would like to be able to do the same thing while both services are behind Identity Aware Proxy.

Following the instructions in IAP docs I have:

  1. Set my app to respond the OPTIONS requests
  2. Changed the setting access_settings.cors_settings.allow_http_options to true using gcloud CLI.

Here is the error I'm facing:

Access to XMLHttpRequest at 'https://api-dot-my-app-dev.appspot.com/api/123' from origin 'https://frontend-dot-my-app-dev.appspot.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

When I make the same requests from localhost to localhost or from service A (client side) to localhost api the requests succeed.

This leads me to believe that the issue is related to Identity Aware Proxy. My only guess is that it's related to the preflight request, which I don't see anything about in the network requests in the browser console.

I would really like to be able to keep both apps behind IAP with their own hostnames while still communicating. Unfortunately, I have about exhausted ideas for how to do this.

In the meantime I have it working using alternative #2 below for now.

Alternatives:

  1. Have the API serve the static site so they are on the same hostname
  2. Use dispatch.yaml to serve both sites from the same hostname

Any ideas if this is possible or what might be going wrong?

Edit: Here is a repo to demonstrate my problem.

Edit 2: According to this article, this functionality used to work and Google said it would be a good idea to support it but offered not timeline.

1

1 Answers

0
votes

Not sure if that can be applied on your use case but I have seen this kind of issue being resolved by allowing CORS preflight request to be passed through IAP by changing the access_settings.cors_settings.allow_http_options to true.