Option 1: Script the login with Puppeteer
Puppeteer is the most flexible approach. It lets you automate the login flow before handing the authenticated page to Lighthouse.Option 2: Use Chrome DevTools
The Lighthouse panel in Chrome DevTools never clears cookies. Log in to your site normally, then open the Lighthouse panel and run an audit. If your authentication depends onlocalStorage or indexedDB, uncheck Clear storage in the Lighthouse panel settings before running.
Option 3: Pass custom request headers
Use the--extra-headers flag to inject an Authorization header or any other header your server requires.
Option 4: Open a debug Chrome instance and log in manually
This approach works when you need to authenticate interactively, such as with SSO or multi-factor authentication.1
Install Lighthouse globally
chrome-debug binary to your PATH.2
Launch the debug Chrome instance
3
Log in to your site
In the Chrome window that opens, navigate to your site and complete the
login process.
4
Run Lighthouse against the authenticated session
In a separate terminal, run Lighthouse using the port number from step 2:Replace
9222 with the port printed by chrome-debug.