question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Is it possible to change the baseURL after the api is created?

See original GitHub issue

Something like this:

this.api = create({
  baseURL:'localhost:8999'
})

this.api.setBaseURL('somefancyapi.com');

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

10reactions
skellockcommented, Nov 7, 2016

Axios allows you, but we should definitely have a way. In fact, exactly like you suggest. šŸ‘

3reactions
skellockcommented, Jan 17, 2017

To change it, youā€™ve got a few options.

  • You can just create a brand new api object with the baseURL being what you want.
  • You can call api.axiosInstance.setBaseURI('xxx') to change the instance (this is the thing Iā€™ll make easier to do that was suggested at the start of this ticket).
  • You can do it per request: api.getThing('myApiCall', {x: 1}, { baseURI: 'swappyswap.com' }).

It sounds like your situation is you connect to an API, then part way through the ā€œsessionā€, you change the APIā€™s sub-domain.

Iā€™d do bullet point 1, personally, unless youā€™ve got a bunch of ā€œstateā€ packed into the API object.

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Retrofit - Change BaseUrl - Stack Overflow
I have a scenario where I have to call an API with the same base URL, e.g. www.myAPIĀ ...
Read more >
Change BaseURL in OnBeforeRequestAdvanced - OutSystems
I see the log doing the replacement fine...but in the integrations tab (logging in ServiceCenter), it's calling the API with the original URL....
Read more >
Retrofit 2 ā€” How to Change API Base Url at Runtime
With this setup you don't have a chance to change the API_BASE_URL constant at runtime. You've change it in the source code, compile...
Read more >
API Server and Base Path - Swagger
In OpenAPI 3.0, you use the servers array to specify one or more base URLs for your API. servers replaces the host ,...
Read more >
How can I change the existing base URL of Artifactory - JFrog
Navigate to Admin -> Configuration-> General Configuration-> General settings -> change Custom Base URL to a new url. Option 2 (If you are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found