Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

226
Views
Cannot Basic Auth from React App with Axios or SuperAgent

I try to make a GET request with axios and I always get 401. This happens only when I send the request from my react app.

axios.get('http://localhost:8080/vehicles', {
        withCredentials: true,
        auth: {
            username: 'admin',
            password: 'admin'
        },
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
        },
    })

Postman GET request with the same credentials and Basic Auth set, works.

If I simply type in my browser the url, a login box appears and with the same credentials, it works, I get what I want.

I tried with SuperAgent too:

Request.get("http://localhost:8080/vehicles")
        .withCredentials()
        .auth('admin', 'admin')
        .then(response => {
            return response.body
        });

Still nothing.

I saw a question related to this one but no one answered it.

(Basic authentication : failure supergaent+OSX , success on superagent+Redhat , success on Postman+OSX,)

Can anyone point me to the right direction?

Thank you for reading.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!