cespon
cespon

Reputation: 5760

Puppeteer: "The information you’re about to submit is not secure"

After submitting a form with Puppeteer, I got this message:

The information you’re about to submit is not secure. Because the site is using a connection that’s not completely secure, your information will be visible to others.

The message was triggered by a insecure Location response header (HTTP resource instead HTTPS).

To solve this, I've been thinking about two options:

  1. Avoid this message. How to avoid it?
  2. 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();
});

Upvotes: 3

Views: 4276

Answers (1)

HatemSat
HatemSat

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

Related Questions