SPATIE

  • Products
  • Open Source
  • Courses
  • Web Development
VacanciesAboutBlogDocsGuidelinesMerch ↗ Log in

Docs Browsershot Miscellaneous-options Adding extra headers to every request

Other versions for crawler v4 v3
    • Introduction
    • Support us
    • Requirements
    • Installation & setup
    • Upgrading
    • Questions and issues
    • Changelog
    • About us

    Usage

    • Introduction
    • Creating images
    • Creating PDFs
    • Creating HTML

    Miscellaneous options

    • Adding extra headers to every request
    • Adding extra headers to the navigational request
    • Changing the language of the browser
    • Changing the value of a dropdown
    • Clicking on the page
    • Connection to a remote chromium/chrome instance
    • Disable sandboxing
    • Fixing cors issues
    • Getting console output
    • Getting failed requests
    • Ignore HTTPS errors
    • Passing environment variables to the browser
    • Performance
    • Prevent unsuccessful responses
    • Sending POST requests
    • Setting an arbitrary option
    • Setting the CSS media type of the page
    • Setting the timeout
    • Setting the user agent
    • Specifying-a-proxy-server
    • Typing on the page
    • Using a pipe instead of a WebSocket
    • Using cookies
    • Using HTTP Authentication
    • Using url for html content
    • Writing options to a file
    • Disabling redirects
    • Read redirect history

Adding extra headers to every request

To add custom HTTP headers to the navigational HTTP request and all resources that make up the page, use setExtraHttpHeaders:

Browsershot::url('https://example.com')
    ->setExtraHttpHeaders(['Custom-Header-Name' => 'Custom-Header-Value'])
   ...
Creating HTML
Adding extra headers to the navigational request
Help us improve this page
Writing Readable PHP

Learn everything about maintainable code in our online course

Help us improve this page
  • Products
  • Open Source
  • Courses
  • Web Development
VacanciesAboutBlogDocsGuidelinesMerch ↗ Log in

Kruikstraat 22, Box 12
2018 Antwerp, Belgium
info@spatie.be
+32 3 292 56 79
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter
  • Bluesky
  • Mastodon
  • YouTube
  • Privacy
  • Disclaimer

+32 3 292 56 79

Our office is closed now, email us instead

    Enter a search term to find results in the documentation.