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

Axios 0.21.1 and 0.20.0 not merging url with baseURL #3663

Closed
sebnapi opened this issue Mar 3, 2021 · 5 comments
Closed

Axios 0.21.1 and 0.20.0 not merging url with baseURL #3663

sebnapi opened this issue Mar 3, 2021 · 5 comments

Comments

@sebnapi
Copy link

sebnapi commented Mar 3, 2021

Describe the bug

I was just encountering the problem locally, that the new axios version is not merging url with baseURL. I found some issues with version 0.19.0 Issue #2190 where the params are not merged. I used the runnable example to showcase my problem:

To Reproduce

https://runkit.com/sebnapi/axios-0-21-1

const axios_newer = require("axios@0.21.1");

const ctr_args = {
    baseURL: "https://httpbin.org",
    url: "/anything",
    params: {
      q: "question",
    }
  };

axios_newer.request().then(function(r) { console.log("axios 0.21", r.data); }).catch(function (e) {console.log(e)})

Expected behavior

Request gets fullfilled with uri appended to baseURL.

Environment

  • Axios Version 0.21.0, 0.20.0, 0.19.0

Additional context/Screenshots

Screenshot 2021-03-03 at 14 48 50

@chinesedfan
Copy link
Collaborator

See #3579 (comment).

@SlinkyPotato
Copy link

Yep I'm having the same issue although slightly different use case

CommonAPI.js

const axios = require('axios');

const someAPI = axios.create({
    baseUrl: 'https://someapiwebsite/v1/',
    timeout: 1000,
    headers: {
        'Some-Api-Version': '1.0.0',
        'Authorization': process.env.MY_TOKEN
    }
});

module.exports = someAPI;

Calling statement

const someAPI = require('../../somehwhere/SomeAPI.js');
const blocks = someAPI.get(`blocks/${FAQ_PAGE_ID}/children`);

@laygir
Copy link

laygir commented Jul 14, 2021

Yup exactly. I'm also having this issue as I just updated my axios version in the project.

I cloned runkit from @sebnapi notice on version 0.21.1 the config.url value is not merged with baseURL.
I'm expecting same behaviour as older versions.

https://runkit.com/liger/60eedbdbb3e7b0001a2dc521

I was able to trace back to this PR: #2391
However this PR should have fixed the relative baseURL issue but somehow absolute baseURL also is not prepended to the url

@richterdennis
Copy link

0.21.4 still not working

@jasonsaayman
Copy link
Member

I have released 0.22.0 please check if that fixes your error, if not please open a new issue :)

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

No branches or pull requests

6 participants