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

321
Views
CORS request not http when authentication MERN stack

I've read multiple answers on this topic, but none of them works for me so far. I've tried changing the request on the client side:

const res = await axios.post(url,
      body,
      {
        headers: {
          'Access-Control-Allow-Origin': '*',
          "Access-Control-Allow-Methods": "*",
          'Content-Type': 'application/json',
          "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept, Authorization"
        },
      }
    );

as well as configuring the CORS on the backend:

app.options("*", cors({ origin: 'http://localhost:3000', optionsSuccessStatus: 200 }));
app.use(cors({ origin: "http://localhost:3000", optionsSuccessStatus: 200 }));

The error message in Chrome is: Access to XMLHttpRequest at 'localhost:8000/api/user/register/' from origin 'http://localhost:3000' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.

On Firefox: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at localhost:8000/api/user/register/. (Reason: CORS request not http).

What am i doing wrong?

edit: I checked the req headers on localhost:8000 (the one i am fetching): enter image description here

Looks like localhost:3000 is allowed, but it still doesn't work

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!