Showing results for 
Search instead for 
Did you mean: 

Setting Host and BasePath dynamically


Setting Host and BasePath dynamically

I'm looking to set host and basePath to override the host and bathPath settings stored in my swagger.json.

I'm using Swagger 2.0 spec and the following for package for swagger UI

"swagger-ui": "^3.22.1"

 Within the documentation there is reference to the following:



which should set the host. I'm having issues on finding a working example of this.


Within App.js I have the following:


    componentDidUpdate() {


        const ui = SwaggerUI({
                domNode: document.getElementById("api-body"),
                url: this.state.definitionLink,
                deepLinking: true,
                docExpansion: true,
                showCommonExtensions: true,
                filter: true,
                requestInterceptor: function (request) {
                responseInterceptor: function (response) {




is the url of the swagger.json


Where in my app would i place the: swaggerUi.api.setHost(<hosturl>)? or is this call incompatible with my version of swagger-ui?


If someone has a working code snipped that would be really helpful.


New Here?
Join us and watch the welcome video:
Read the Latest News
Top Kudoed Authors
Top Kudoed Posts