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

138
Views
NodeJS Prevent redirect to main route on long requests

I Have NodeJS post route like that:

const Sleep = async (milliseconds) => {
    await new Promise(resolve => setTimeout(resolve, milliseconds));
}
app.post("/read_x2", async (req, res) => {
    while (true) {
        var done = false;
        await Sleep(1000);
        // await mysqlconnection // if found: done = true;
        if(done) {
            return;
        }
        await Sleep(1000);
    }
}

})

the post route is like: https://sub.domain.com/read_x2 when i do post to that url, it should wait for sql to be done, time is unlimited to wait, maybe wait 1 sec and maybe 10 minutes, anyway when i do post request, after some time (less than minute) request automatically redirected to main domain https://sub.domain and got results despite Node code still waiting mysql to be done

What is the reason of this issue and how to solve it ?

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