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

185
Views
why does useeffect sending a cross origin request get 403 but type the same url in browser get 200?

I use http-proxy-middleware to get my cross origin data, it worked in browser, but didn't in react.

It returned GET http://localhost:3000/api 403 (Forbidden) and Uncaught (in promise) Error: Request failed with status code 403

react

export default memo(function Component() {
  useEffect(() => axios.get('/api').then(res => console.log(res.data)), [])
    return (
    <div>
      // ....
    </div>)
});

setupProxy.js

const { createProxyMiddleware } = require('http-proxy-middleware')
module.exports = function (app) {
    app.use(
        createProxyMiddleware('/api', {
            target: 'api.com',
            changeOrigin: true,
            pathRewrite: {
                '/api': ''
            }
        })
    )
}

I checked the differences between 403 and 200 headers, only Sec-Fetch- headers are different.

about 4 years ago · Juan Pablo Isaza
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!