Ocelot icon indicating copy to clipboard operation
Ocelot copied to clipboard

Can Ocelot be used side-by-side in existing project?

Open sweeperq opened this issue 3 years ago • 3 comments

I created a simple test api, made sure it was working. Then downloaded Ocelot from NuGet and wired in. When I fired up the Web app, Ocelot broke the routes for the hello world welcome page app.MapGet("/", () => "Hello World!"); and test api controller even though neither match the UpstreamPathTemplate. I created a separate external route for The Movie Database (TMDB), fired it up again, and that route did return data. Left me wondering if Ocelot can be used side-by-side in the same web application, or if it hijacks all routes and needs to be put in its own environment?

sweeperq avatar Nov 24 '21 22:11 sweeperq

Hello @sweeperq ,

API Gateways should be used in front of APIs. Why would you like to run it side-by-side?

vitorelli avatar Apr 29 '22 17:04 vitorelli

@vitorelli The internal API I was developing at the time was in .Net, but I also planned on using external APIs. I Googled how to securely hide API credentials from a React front-end. There was a lot of bad advice to put it in certain files or obfuscate it, all of which can be unwrapped with the JavaScript debugger. Then I stumbled upon the terms "Reverse Proxy" and "API Gateway" which led me to Ocelot.

After reading the project page and setup documentation it wasn't clear to me that Ocelot was meant to be a stand-alone application. I pulled it into my API project via NuGet thinking I could use specific URL patterns to wrap my API calls. However, I discovered that Ocelot took over all of the routing. I wasn't sure if I was missing a configuration step, or if it wasn't meant to be used this way (hence the above question).

sweeperq avatar Apr 29 '22 18:04 sweeperq

If you want to hide API credentials, please take a look at https://github.com/openiddict/openiddict-core (OpenID Connect). This library can run side-by-side with other APIs and work pretty well with Ocelot.

vitorelli avatar Apr 29 '22 18:04 vitorelli