[Feature] route handler to support redirects
See original GitHub issueContext:
- 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:
- Created 3 years ago
- Reactions:2
- Comments:7 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As pointed in #3994, this is currently by design. Let me update this as a feature request.
Closing it for now as per above…