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

248
Vistas
How do I solve the error of forcing a call to https in javascript?

How do I solve the error of forcing a call to https in javascript?

Here is my sse source.

const eventInit = () => {

    console.log("eventInit called");
    const url = `${_EVENT_PUSH_ENDPOINT}/itf/subscribe`
    //subscribe to the event
    var httpRequest = new XMLHttpRequest();
    httpRequest.open("GET",url, true);
    httpRequest.setRequestHeader("Accept", "text/event-stream");
    httpRequest.send();
const eventSource = new EventSource(url);

    eventSource.onopen = (event) => {
        console.log('sse open');
    }

    eventSource.onerror = (event) => {
        if (event.readyState == EventSource.CLOSED) {
            console.log('sse close');
        } else {
            console.log("onerror", e);
        }
    }

    eventSource.addEventListener('myEvent', function (event) {
        const data = JSON.parse(event.data);
        if(data.positionYn == "Y"){
        data.dvcStatus = data.poiStatus
            init();
           soundControl.control(data)
            drawHtml.eventListViewer(data); // Draw the list of viewers
        }
    }, false);

}

At this time, the following error occurs.

eventCtrl.js?v=1.6:87 Uncaught ReferenceError: e is not defined
    at EventSource.eventSource.onerror(eventCtrl.js?v=1.6:87)
eventSource.onerror @ eventCtrl.js?v=1.6:87
error (asynchronous)
eventInit @ eventCtrl.js?v=1.6:83
(anonymous) @ index.js:495
:8330/itf/subscribe:1 GET https://localhost:8330/itf/subscribe net::ERR_SSL_PROTOCOL_ERROR

output the url in the chrome developer tools,

url
'http://localhost:8330/itf/subscribe'

It outputs normally, but inside JavaScript, it continues to call https://localhost:8330/itf/subscribe.

I don't know why it calls https even though the url is http.

I am wondering how can I solve this problem.

Best Regards!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The server probably has an URL rewriting rule in place, forcing https. If you don't have access to the server configuration and can't create/control .htaccess file, then you'll have to contact your back-end developer for help.

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