origin: Path-based routing does not work as expected
When creating a route for a service in Origin, I’m seeing behavior that is unexpected. Before calling it a bug, I figured I would get your opinions by describing what I’m seeing and what I expect. If we agree it’s a bug, I’d be happy to submit a PR. Here goes…
Let’s say I’ve got a REST API being deployed as a service on Origin. When I create a new route, I give it a path of /my-api. When I access my REST API using /my-api/endpoint1, my application sees a request for /my-api/endpoint1 and the result is a 404. The reason for this is my application is written to handle the /endpoint1 path, not /my-api/endpoint1.
As an application author, I would not expect that the base path used for routing to be seen by my container. What I would expect is that a request for /my-api/endpoint1 to be seen as /endpoint1 at the service/pod/container level.
I originally ran into this while going through the quick start guide. When I deployed the nodejs-ex project, I wanted to use path-based routing so that I didn’t need to update my /etc/hosts file again. To my surprise, the application didn’t work with path-based routing but worked fine with host-based routing. Ironically, within an hour a colleague of mine ran into the exact same problem but with a simple Ruby on Rails container he was testing. (Here is a little more detail on the exact scenario I ran into: https://github.com/openshift/nodejs-ex/issues/31)
With all of this being said, am I wrong in my expectation?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 7
- Comments: 17 (6 by maintainers)
/reopen
Here is my use case: Front-end application running in a POD. Back-end running in a différent POD.
Route are: myapp.example.com/ --> Front-end myapp.example.com/api --> Back-end
I would like to be able to rewrite the path and remove the “/api” portion, so the Backend would not see this path. Otherwise, I have to tell evey backend developer to add a “/api” or something else prefix to their application.
Just like proxyTable in webpack:
proxyTable: { ‘/api’: { target: ‘http://localhost:3000’, changeOrigin: true, pathRewrite: { ‘^/api’: ‘’ }, }
Thanks for your help !