I have an API Gateway running in .NET Core 3.1
using Ocelot
. Everything works fine as expected.
Now I'm trying to substitute the downstream host during the middleware process.
Here's my configuration.json:
{
"Routes": [
{
"DownstreamPathTemplate": "/api/product/getProduct",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": "44300"
}
],
"UpstreamPathTemplate": "/getProduct"
}
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost:62012/"
}
}
I want to change the Host
in the DownstreamHostAndPorts
at runtime as by this time from grabbing the claims out of the jwt
I will know the tenant the user belongs to therefore know where to route there request.
To be more clear, a request to the gateway comes in at http://localhost:62012/api/getProduct,
Then I get the tenant from the jwt
in the request that made this call and then redirect the request to the relevant api
like so
http://tenant1.com/api/product/getProduct or http://tenant2.com/api/product/getProduct