Student of Science
Student of Science

Reputation: 492

axios is not prepending default baseUrl in any request even thought it is set

I set axios.default.baseUrl to the api subdomain of a local project. When making requests from the admin subdomain of the site, axios does not prepend the baseUrl.

Instead, it sends the request to admin.example.test (in my case, 'example' is 'loa'. You can see it in the image below).

enter image description here

How to make axios prepend the default baseUrl in every request? So that I don't have to write something like axios(axios.defaults.baseUrl + url).

Upvotes: 1

Views: 698

Answers (1)

Student of Science
Student of Science

Reputation: 492

Instead of axios.defaults.baseUrl = "http://api.example.test", it should be axios.defaults.baseURL = "http://api.example.test".

I felt kind of stupid for not seeing this. But I will answer my own question because maybe it can help somebody who has the same problem.

Upvotes: 1

Related Questions