Este problema solo ocurre en Firefox, también probé Chrome y está bien allí. Creé una página web simple con fines de prueba para reproducir el problema. El enlace está aquí . Los contenidos de la página son:
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>URL Test with basic auth</title> <meta name="description" content="Test for Firefox and handling of history API when basic auth is present"> <meta name="author" content="Ondrej"> </head> <body> <h1>URL Test</h1> <script> const addParameter = () => window.history.replaceState(null, '', '/?ok=1') window.addEventListener('DOMContentLoaded', () => { addParameter() }) </script> </body> </html>Al cargar el sitio web, quiero agregar un parámetro de consulta a la URL mediante el uso de la API de historial replaceState .
Ahora, el servidor web no contiene ninguna autenticación básica HTTP real, pero si lo usa como parte de la URL, arroja el error. Intente copiar y pegar esto en su barra de URL:
https://user:pass@offbeat-cattle.surge.sh
El problema solo ocurre en el navegador Firefox (probado en 94.0.1 ) donde no puede agregar el parámetro de consulta a la URL y arroja este error en la consola:
Uncaught DOMException: The operation is insecure.