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

138
Vistas
HTTP redirects when working with REST APIs

One of my very obvious knowledge gaps is HTTP redirects and what role they play when working with AJAX requests and APIs. I've read this MDN guide on redirects. I know that redirects return a 3xxstatus code and provide a Location response header. Furthermore, the MDN guide states this:

When browsers receive a redirect, they immediately load the new URL provided in the Location header.

This makes sense to me when dealing with HTML directly (e. g. submitting a form and receiving a redirect after).

When dealing with API's it all becomes a little fuzzy. I've read this quora post where most participants say that redirects don't play any role in REST. When I tested this, the browser made a request to the URL provided in the Location header but did not navigate to it. Instead, I would just load the HTML response if the location was on the same origin and fail with a CORS error for different origins.

I'm currently trying to solve this problem: I send an AJAX payload to an API and want to redirect the user to a different domain (& origin) upon completion. My question is this: Do I send back the redirect URL as a payload and navigate the user to the new origin with the window.location object (javascript) or can this be handled with a HTTP redirect?

I'd love some help.

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