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

149
Vistas
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 Respuestas
Responde la pregunta

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 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