Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!