The API Gateway could proxy HTTP "redirect" requests for synchronous requests. These happen when a function returns a HTTP redirect status code plus a Location: scheme://url header.
The of-watchdog and stateless microservices can return custom / bespoke HTTP headers.
This does not apply or make any sense for asynchronous invocations.
This technically "works as designed" in that any Location/redirect request is followed by the Golang proxying code and therefore if a function asks to redirect to https://google.com -> the API gateway's proxy code will download that page and return it.
I implemented this for the OpenFaaS Cloud Auth service, the same approach can be applied to the http.Client. https://github.com/openfaas/openfaas-cloud/blob/3d3ed09707817b436751b279973d6f26191930a4/router/main.go#L34
I.e. with node8-express:
"use strict"
module.exports = (event, context) => {
context
.headers({'Location': 'https://www.google.com/'})
.status(307) // Temporary
.succeed('Page has moved.')
}
Reported by a user who wanted to do OAuth redirects from a function. https://github.com/openfaas-incubator/of-watchdog/issues/34
The watchdog / of-watchdog may need an additional change, but the gateway can be proven out just with a container exposing port 8080. https://docs.openfaas.com/reference/workloads/
It goes without saying that this needs to be fully tested and with not just the "happy path" scenario.
I've tried this with a stateless microservice adapted from the node8-express template, and the code patch above. It worked :+1:
Separate testing/changes may be needed for the watchdogs.
Feature released via 0.9.7
Derek close: released.
Awesome!
Most helpful comment
Feature released via 0.9.7