Making requests relative to current domain
See original GitHub issue### Summary
Hello,
I’m developing a web app and I’m using axios. I was a very happy user until I had to deploy to my production server. On the production server, my app is served under a subdomain, so making the entire application work both on a root domain (for development) and on a subdomain was a bit painful. However, for my surprise, making axios requests work on both sides was very easy. So easy that I’m not sure if it is intentional or a bug. Before my requests was like
axios.get('/api/licenses')
So serving the app from https://example.com/licenses
resulted on a request to https://example.com/api/licenses
instead of the expected https://example.com/licenses/api/licenses
.
After that, I just tried to remove the prefixing slash, so my request looked like:
axios.get('api/licenses')
That produced the desired result of making the request to https://example.com/licenses/api/licenses
. I am very happy with this, because now I can develop my app without hassle. However, this behavior is not documented on any place, all the examples makes requests to the root of the domain, and I’m scared of this cool feature disappearing on future releases.
### Context
- axios version: e.g.: v0.16.1
- Environment: chrome 57
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:6 (1 by maintainers)
This is just how relative URLs work in the browser. Axios doesn’t have anything special about it.
What about
axios.get('./path')
? Why isn’t that respecting the relative of the path ?