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

118
Vistas
Safe way to get origin

I am maintaining an application in which I access the origin via window.origin in order to build some URLs.

It works... but I had a security alert because it seems that this variable can be written. For example, go on Google and try that in the dev tools :

> window.origin
<   'https://www.google.com'
> window.origin='yolo'
<   'yolo'
> window.origin
<   'yolo'

This is indeed a security issue as my URLs are built like this : window.origin + "/path/to/other/app" If an attacker could find a way to execute this script window.origin = 'evil.com', customers would be redirected to an unexpected URL.

I found that I could call location.origin instead, which seems safer :

> location.origin
<   'https://www.google.com'
> location.origin='yolo'
<   'yolo'
> location.origin
<   'https://www.google.com'

But does it work on every browser ? Is there a recommended way of getting the origin ?

about 4 years ago · Santiago Gelvez
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