Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not the correct url value #2365

Closed
long-woo opened this issue Aug 20, 2019 · 3 comments
Closed

Not the correct url value #2365

long-woo opened this issue Aug 20, 2019 · 3 comments
Assignees

Comments

@long-woo
Copy link

Describe the bug

After upgrading to 0.19.0, the url obtained in the request interceptor is missing baseURL. When I dropped to 0.16.1, the result was correct.

To Reproduce

Axios.defaults.baseURL = '/api'
Axios.interceptors.request.use(
  config => {
    console.log('config', config)
    console.log('config.url', config.url)

    return config
  },
  error => {
    Vue.nprogress.done()

    return error
  }
)

Expected behavior

Return correctly, bring baseURL.

Environment:

  • Axios Version [0.19.0]
  • OS: [OSX 10.13.4]
  • Browser [Chrome]
  • Browser Version [76]

Additional context/Screenshots

image

@Lenny-Hu
Copy link

Lenny-Hu commented Nov 14, 2019

我使用的v0.19.0也是这种情况,我在拦截器内基于url做了一些操作,发现config.url并不是以axios.defaults.baseURL开头的

@Alanscut Alanscut self-assigned this Nov 14, 2019
@Alanscut
Copy link
Collaborator

This breaking changes due to PR #950 which fixed issue #949.
This commit is used to make the baseURL that rewriting in the interceptor take effect, and the full url should be merged during the request. So config.url must be a relative path in interceptor, otherwise we can‘t build the correct full url.

But I don't think this change will affect the operation you want to do, in interceptor, the full url you wanted is config.baseURL + config.url, so you can do whatever you want on the full url by manipulating the config.url and config.baseURL.

@Alanscut Alanscut removed the type:bug label Nov 14, 2019
@Alanscut
Copy link
Collaborator

config.url without baseURL could avoid repeatedly adding baseURL to the front of requestURL when retry the request. Detailed description: #1628, #2391

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants