question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] route handler to support redirects

See original GitHub issue

Context:

  • Playwright Version: 1.4.2
  • Operating System: Mac
  • Node.js version: 14.12.0
  • Browser: All

Code Snippet

const playwright = require('playwright');

(async () => {
  for (const browserType of ['chromium', 'firefox', 'webkit']) {
    const browser = await playwright[browserType].launch({ headless: true });
    const context = await browser.newContext();
    const page = await context.newPage();

    let seenRequest = false;
    page.route('**', (route) => {
      const url = route.request().url();
      if (url.includes('account.bbc.com')) {
        seenRequest = true;
      }
      route.continue();
    });

    await page.goto('https://www.bbc.co.uk/');
    await page.click('"Sign in"');
    await page.waitForRequest(/account\.bbc\.com/);
    if (!seenRequest) {
      console.error('Did not see request');
    }
    await browser.close();
  }
})();

Describe the bug

When clicking ‘sign in’ there is a 302 redirect from https://session.bbc.co.uk/session to https://account.bbc.com/.

It looks like the handler is not called again with the new url on the redirect.

The docs say:

If request gets a ‘redirect’ response, the request is successfully finished with the ‘requestfinished’ event, and a new request is issued to a redirected url.

So I’m expecting the handler to be called again with the new url.

I’m expecting “Did not see request” not to be logged in my example, but it is.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dgozmancommented, Sep 30, 2020

As pointed in #3994, this is currently by design. Let me update this as a feature request.

0reactions
pavelfeldmancommented, Oct 20, 2020

Closing it for now as per above…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to implement redirects in Next.js - LogRocket Blog
Redirects enable users to transfer an executed URL to a new URL to reroute an incoming request from one path to another.
Read more >
Redirects With Express - Mastering JS
The res.redirect() function lets you redirect the user to a different URL by sending an HTTP response with status 302.
Read more >
Redirections in HTTP - MDN Web Docs - Mozilla
In HTTP, redirection is triggered by a server sending a special redirect response to a request. Redirect responses have status codes that start ......
Read more >
Working with Redirects and Rewrites - Gatsby Cloud
Redirects are settings in the network layer that allow you to route traffic from one url path to another with little to no...
Read more >
Forward request to alternate request handler instead of redirect
You just need to invoke the corresponding route handler function. Option 1: route multiple paths to the same handler function.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found