4

port is getting added at the Downstream url. i want to access a micro service hosted in heroku. need to avoid port. Please help.

Its working in local dev environment. But not working after deployment in Heroku.

{
  "ReRoutes": [
    {
      "DownstreamPathTemplate": "/api/{catchAll}",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "catalogapi-pinaki.herokuapp.com"
        }
      ],
      "UpstreamPathTemplate": "/cat-logApi/{catchAll}"

    }

  ],
  "GlobalConfiguration": {
    "BaseUrl": "http://localhost"
  }
}

The Downstream Url should be "https://catalogapi-pinaki.herokuapp.com/api/CatalogApi/GetAllItems".

Error: message: Downstream url is https://catalogapi-pinaki.herokuapp.com:56084/api/CatalogApi/GetAllItems

my Error message

2 Answers2

2

Did you try to force to the default port? You can specify the port using the port attribute inside "DownstreamHostAndPorts" like so:

     {
        "ReRoutes": [
            {
            "DownstreamPathTemplate": "/api/{catchAll}",
            "DownstreamScheme": "https",
            "DownstreamHostAndPorts": [
                {
                    "Host": "catalogapi-pinaki.herokuapp.com",
                    "Port": 443
                }
            ],
            "UpstreamPathTemplate": "/cat-logApi/{catchAll}"
            }
        ],
        "GlobalConfiguration": {
            "BaseUrl": "http://localhost"
        }
    }
deeproute
  • 151
  • 1
  • 11
0

We also faced same issue. we fixed issue using FIX 2.

FIX 1: services.AddOcelot(Configuration.GetSection("OcelotSettings")) .AddDelegatingHandler(true);

Inside OcelotRerouteHandler you can replace your url and construct new httprequestmessage. Refer : https://ocelot.readthedocs.io/en/latest/features/delegatinghandlers.html

Fix2:

"DownstreamPathTemplate": "/subdomain/api/{catchAll}"

"Host": "catalogapi-pinaki.herokuapp.com",

If you have any subdomain , dont add it in HOST add in DownstreamPathTemplate. For https port can be 443.

Vetrivel mp
  • 1,214
  • 1
  • 14
  • 29