Reputation: 71
Let's setup the basics: I'm using Google Api Gateway with differents backends like Google Cloud Function.
First, I was parsing the req
paramters with a switch
statement on a header containing the original request url. (Very messy but working)
So I decided to use an express app instead for my cloud function.
But here is the thing: my functions always receive /
from the gateway and generate raging errors like CANNOT GET / when my path is https://mygateway/api/subservice/action
So my question is: can I change the handling of the express app to parse my header containing the original request url and not the default path url?
Here is a part of my config:
{
"swagger": "2.0",
"info": {
"title": "my API",
"version": "1.0.0"
},
"basePath": "/api",
"host": "mygateway.[REGION].gateway.dev",
"schemes": [
"https"
],
"paths": {
"/subservice/action": {
"get": {
"x-google-backend": {
"address": "https://[REGION]-[ProjectID].cloudfunctions.net/[mycloudfunction]"
},
"security": [
{
"jwt_security": []
}
],
Upvotes: 0
Views: 622
Reputation: 71
I found on this question something similar that guided my search of the response possible duplicate here
According Google's explanation of path translation when we use x-google-backend
, the backend will only receive the basic request. we have to define with the parameter path_translation
the behaviour we expect. In my case, I want to receive the same path so i use APPEND_PATH_TO_ADDRESS
Upvotes: 2