Reputation: 5760
After submitting a form with Puppeteer, I got this message:
The message was triggered by a insecure Location
response header (HTTP resource instead HTTPS).
To solve this, I've been thinking about two options:
About option 2, I tried the following:
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', request => {
console.log('Request', request.url());
if (request.url().startsWith('http://')) {
console.log('HTTP Request')
let secureUrl = request.url().replace('http://', 'https://');
// TO-DO: set here the 'secureUrl' to the request.
}
request.continue();
});
Upvotes: 3
Views: 4276
Reputation: 76
This page seems to be triggered before puppeteer request event and thus cant be modified, a workaround may just be :
if (await page.$('.insecure-form') !== null) {
await page.click('#proceed-button')
await page.waitForNavigation({ waitUntil: 'networkidle0' })
}
Upvotes: 3