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

Why can this request be successfully sent? The base URL doesn’t end with a /, and the request URL doesn’t start with one either. #6695

Open
liuyangjuncong20202570 opened this issue Nov 9, 2024 · 1 comment

Comments

@liuyangjuncong20202570
Copy link

Describe the issue

Why can this request be successfully sent? The base URL doesn’t end with a /, and the request URL doesn’t start with one either.

Example Code

const request = {
  admin: createAPI('http://localhost:8080/api')
};

function createAPI(url) {
  // 构建不同端口的异步请求数据
  const axiosData = axios.create({
    baseURL: url,
    timeout: 7000
  });
  return axiosData;
}

request.admin
    .get('sysmangt/professionmangt')
    .then(res => {
      if (res.code === 200) {
        console.log(res.data);
      }
    })

Expected behavior

No response

Axios Version

1.6.5

Adapter Version

HTTP

Browser

Edge

Browser Version

latest

Node.js Version

18

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response

@sravanth-space
Copy link

Hi @liuyangjuncong20202570, I have tried this, and it's working fine.
image

https://codesandbox.io/p/sandbox/try-axios-forked-chmhw7

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

2 participants