
How to screenshot authenticated pages (login-gated content)
How to Screenshot Authenticated Pages Capturing a public URL is straightforward. Capturing a dashboard, invoice, or any page that requires login is where headless browser automation breaks down: you need to log in first, preserve the session cookie, pass it to the screenshot request, and handle session expiry. PageBolt lets you pass cookies and headers directly — no login automation required. Pass a session cookie If your app uses cookie-based sessions (most server-rendered apps do): const res = await fetch ( " https://pagebolt.dev/api/v1/screenshot " , { method : " POST " , headers : { " x-api-key " : process . env . PAGEBOLT_API_KEY , " Content-Type " : " application/json " , }, body : JSON . stringify ({ url : " https://yourapp.com/dashboard " , cookies : [ { name : " session " , value : " your-session-token-here " , domain : " yourapp.com " , }, ], fullPage : true , blockBanners : true , }), }); const image = Buffer . from ( await res . arrayBuffer ()); Pass a Bearer token via head
Continue reading on Dev.to Webdev
Opens in a new tab


