Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Application router is redirecting to wrong URL when trailing slash (/) is removed

Mohit_Agarwal
Associate
Associate
0 Kudos
310

Hi

I have defined a route in xs-app.json file for the path /mealapi/docs.

When I use the URL: http://localhost:5000/mealapi/docs/, it works just fine and shows the required page.

The problem appears when I don't use the trailing slash (/) i.e., URL: http://localhost:5000/mealapi/docs

It automatically redirects me to the URL: localhost:5000/api/docs/ and I am not able to figure out what's the reason behind this behavior.

I have tried every possible way out to get to the same page when trailing slash is not used but no luck.

Below is my xs-app.json:

{ "authenticationMethod": "none", "routes": [ { "source": "^/mealapi/docs(.*)", "destination": "meal-srv" } ]}

default-env.json:

{ "destinations": [ { "name": "meal-srv", "url": "http://localhost:1000/" } ]}

I have an endpoint in meal-srv which serves the swagger documentation:

app.use( "/mealapi/docs", swagger.serve, swagger.setup(swaggerDoc.SWAGGER_DOCUMENT));
0 REPLIES 0