I have been testing GCP's API Gateway and found a problem in handling my Django's REST APIs running on GAE.
I got ERR_TOO_MANY_REDIRECTS error when accessed the API with the URL generated by the Gateway (it's like https://gw--fake-test-xyz9ry1.uk.gateway.dev/hello).
My Gateway's API Config looks like below (Note: all URLs are fake):
swagger: '2.0'
info:
title: test-01
description: Sample APIs through API Gateway with GAE
version: 1.0.0
schemes:
- https
produces:
- application/json
paths:
/hello:
get:
summary: Just a simple get function
operationId: hello
x-google-backend:
address: https://myfakeapp.uk.a.appspot.com/hello/
responses:
'200':
description: A successful response
schema:
type: string
I confirmed that the access to the original GAE's API (https://myfakeapp.uk.a.appspot.com/hello/) worked fine.
My guess was that Django's APPEND_SLASH setting was trying to append a slash and it caused the redirection trouble. To solve it, I set APPEND_SLASH = False in settings.py in Django and redeployed the GAE app and recreated the Gateway. Since the URL with slash was set in the x-google-backend address, I thought the Gateway would transfer the request to that address.
When I accessed the API with the GW's URL, however, the response was 404 error saying the request URL was https://myfakeapp.uk.a.appspot.com/hello (Note that there is no trailing slash in this URL). The slash in the x-google-backend address value in API Config seemed to be ignored.
How can I map Django's APIs to the Gateway's URLs without problems?
I was able to map my Cloud Run's API (which is Flask-based) to the Gateway, but I need to use the APIs by Django running on GAE.