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

147
Views
Cannot execute context.route in for loop

I'm using route.abort() to block some URLs.

When I'm using code like this:

await this.context.route(/a.net/, route => route.abort());

works as expected.

BUT since I have a lot of routes to block instead of writing multiple lines of code above I wanted to create config with routes to block and execute await in for loop.

My config.ts like:

export const config = {
    use: {
        some_list: '/a.net/,/b.net/,/c.net/'
    },
};

rest of the code to block all routes from list:

let listOfResources = config.use.some_list.split(',')
for (let value of listOfResources) {
        await this.context.route(value, route => route.abort());
}

but in the above For loop the aborting or routes is not happening, could anyone help me with that?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

let endpoints = ['/a.net', '/b.net', '/c.net']

 endpoints.forEach((path) => {
      this.context.route(path, route => route.abort());
    });

I'm not very familiar with route.abort() function but maybe this could 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!