Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

247
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda