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:
- Avoid this message. How to avoid it?
- Intercept the HTTP requests and modify them to HTTPS request. How to do that?
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();
});
