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

179
Vistas
Puppeteer how to send PUT request to the redirected page

I am trying to send PUT request to the final URL but before final URL, there is a redirect. Also sending a fetch request inside final URL page is also fine. when I go to devtools console, write fetch from there also works but I need to do it inside the code, of course.


When I set await page.setRequestInterception(true); and page.once('request', (req) => {...}) it sends put request to the first page which I dont want it to do that.

Let's say first URL is https://example.com/first --> this redirects to final URL
final URL https://example.com/final --> this is where I want to send PUT request and retrieve status code.
I have tried setting a timer or getting current url with page.url() and trying some if else statements, but did not work.
here is my current code;

app.get('/cookie', async (req, res) => {
  puppeteer.use(StealthPlugin());

  const browser = await puppeteer.launch({
    headless: false,
    executablePath: `C:/Program Files (x86)/Google/Chrome/Application/chrome.exe`,
    defaultViewport: null,
    args: ['--start-maximized'],
    slowMo: 150,
  });
  const page = await browser.newPage();
  await page.setUserAgent(randomUserAgent.getRandom());


  page.setDefaultNavigationTimeout(0);
  page.setJavaScriptEnabled(true);  

  await page.goto(
    'finalURL',
    { waitUntil: 'load', timeout: 0 }
  );
  await delay(5000);
    
await page.setRequestInterception(true);
page.once('request', (request) => {
  request.continue({
    method: 'PUT',
  });

  page.setRequestInterception(false);
});


  let statusCode;
  await page.waitForResponse((response) => {
    statusCode = response.status();
    return true;
  });

  res.json(statusCode);
});
about 4 years ago · Juan Pablo Isaza
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