Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Headless Chrome is not redirecting

We're using headless Chrome for an application testing. We have a page that refuses to redirect in headless mode but redirects perfectly fine when not running headless. The response header contains the URL to redirect to, and a 302 status code is returned.

What would cause Chrome to behave differently when running in headless mode? Is there any logging that would help me to determine why the redirect isn't working as expected?

Edit: Found some more info. It looks like I'm unable to redirect to sites with bad certs. How can I deal with ERR_CERT_AUTHORITY_INVALID when running Chrome in headless mode?

like image 435
Nael Avatar asked Sep 07 '17 17:09

Nael


2 Answers

as to date seems like --enable-features=NetworkService solves the issue of self signed certificated in headless mode

like image 96
Daniel Avatar answered Nov 18 '22 00:11

Daniel


I was having the same issue and as you pointed out it happens with sites that have bad certificates. Passing the --ignore-certificate-errors flag didn't work at the time of the original post as there was a bug.

Some options to pass to have chrome-headless send more debugging info: --log-level=0 --enable-logging --v=1 bug tracker for chrome/chromium headless not accepting the --ignore-certificate-errors flag: bugs.chromium.org/p/chromium/issues/detail?id=721739 – karlos Dec 7 '17 at 20:15

For anyone reading now the bug was patched recently here: https://chromium.googlesource.com/chromium/src.git/+/c8f0691b18dc5d941d5b6b3c67a483da02400670

And the --ignore-certificate-errors flag should allow redirects to occur when using headless chrome for sites with bad certificates.

like image 28
poppa_nick Avatar answered Nov 18 '22 00:11

poppa_nick