Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

189
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda