axios icon indicating copy to clipboard operation
axios copied to clipboard

While calling the API axios adds an extra '/' in request at the end (not base url)

Open buhshanpjoshi opened this issue 11 months ago • 4 comments

Describe the bug

Hey, If url contains the text 'post' in the url its observed axios is adding extra '/' at the end while calling the api which results into 404 Not found.

e.g. formed url while calling - https://hostname/users/bhushan.joshi@gmail/EMP/temp-auth-method final url - https://hostname/users/bhushan.joshi@gmail/EMP/temp-auth-method

But when its had 'post' in the url e.g. formed url while calling - https://hostname/users/bhushan.postel@gmail/EMP/temp-auth-method OR https://hostname/users/bhushan.abcpostxx@gmail/EMP/temp-auth-method final url - https://hostname/users/bhushan.postel@gmail/EMP/temp-auth-method**/** (adds extra slash in it)

To Reproduce

No response

Code snippet

const response = await endpoint().put(`users/${userId}/${userType}/temp-auth-method`,
    payload,
    { headers: { 'Csrf-Token': 'nocheck' } }
  );

Expected behavior

No response

Axios Version

^0.21.1

Adapter Version

No response

Browser

chrome,IE

Browser Version

No response

Node.js Version

No response

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response

buhshanpjoshi avatar Jan 10 '25 08:01 buhshanpjoshi

Does this have any impact?

msafwankarim avatar Jan 24 '25 14:01 msafwankarim

Yes, it breaking API call

rkdesign avatar Jul 21 '25 15:07 rkdesign

can i contribute in this issue

Shruti2110-coder avatar Oct 11 '25 18:10 Shruti2110-coder

Hello,

I've investigated this issue and my findings suggest that this is not a bug in Axios.

Method: I used an Axios request interceptor to log the exact URL being sent, just before it leaves the client.

Result: The logged URL was correctly formed, even when it contained the word "post". It did not have the extra trailing slash.

Image

Conclusion: This strongly indicates that the extra slash is being added by a server-side redirect (like a 301 or 302 response) after the request is sent. The problem lies in the server's configuration, not the Axios library.

I believe this issue can be closed.

Huzaif-nabi avatar Oct 17 '25 08:10 Huzaif-nabi