New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Connect Options - Allow Authorization Header #7218
Comments
Been looking into this myself. It seems like it may only be relevant when used from Node.js. In the browser, this uses the javascript websocket (https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket)
which doesn't allow you to set headers. Within Node.js it uses the https://github.com/websockets/ws package
which should allow you to set headers (https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketaddress-protocols-options) via Node.js's http(s).request options. |
We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days. |
Please leave open :) |
We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days. |
still valid |
@jayflo Good catch! Finally got around to experimenting with some local changes using
Would be great to be able to optionally configure additional headers from |
… environment (#9314) **What kind of change does this PR introduce?** I have browsers pool in some cloud. I want that only users with access will be able to connect to them. So they must provide token through headers. But puppeteer does not allow to send headers when connected to browser by ws connection. So I added this feature. Closes #7218
🤖 I have created a release *beep* *boop* --- <details><summary>puppeteer: 19.4.0</summary> ## [19.4.0](puppeteer-v19.3.0...puppeteer-v19.4.0) (2022-12-07) ### Features * **chromium:** roll to Chromium 109.0.5412.0 (r1069273) ([#9364](#9364)) ([1875da6](1875da6)), closes [#9233](#9233) ### Dependencies * The following workspace dependencies were updated * dependencies * puppeteer-core bumped from 19.3.0 to 19.4.0 </details> <details><summary>puppeteer-core: 19.4.0</summary> ## [19.4.0](puppeteer-core-v19.3.0...puppeteer-core-v19.4.0) (2022-12-07) ### Features * ability to send headers via ws connection to browser in node.js environment ([#9314](#9314)) ([937fffa](937fffa)), closes [#7218](#7218) * **chromium:** roll to Chromium 109.0.5412.0 (r1069273) ([#9364](#9364)) ([1875da6](1875da6)), closes [#9233](#9233) * **puppeteer-core:** keydown supports commands ([#9357](#9357)) ([b7ebc5d](b7ebc5d)) ### Bug Fixes * **puppeteer-core:** avoid type instantiation errors ([#9370](#9370)) ([17f31a9](17f31a9)), closes [#9369](#9369) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Feature Request
I'd like to connect to a
browserWSEndpoint
that is protected by authentication. It would be nice to be able to provide anAuthorization Bearer <token>
on the connection, and every request thereafter to that endpoint.I'm specifically wanting the Authorization Header, but this probably could just be generic to allowing any headers on all requests.
I vision within the
connect
options, provide aheaders
optionhttps://github.com/puppeteer/puppeteer/blob/v9.1.1/docs/api.md#puppeteerconnectoptions
Example:
I'd imagine the change would happen here:
puppeteer/src/common/BrowserWebSocketTransport.ts
Line 21 in 943477c
To be something similar to:
websockets/ws#473 (comment)
I did see
page.setExtraHTTPHeaders(headers)
, but I don't think this what I'm looking for as it shouldn't just be for a specific page, but for all websocket requests to the server.https://github.com/puppeteer/puppeteer/blob/v9.1.1/docs/api.md#pagesetextrahttpheadersheaders
The text was updated successfully, but these errors were encountered: