-
-
Notifications
You must be signed in to change notification settings - Fork 366
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
Launcher with custom http.Client #1121
Comments
package main
import (
"context"
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/cdp"
"github.com/go-rod/rod/lib/launcher"
)
func main() {
l := launcher.MustNewManaged("")
u, h := l.ClientHeader()
h.Set("My-Header", "my-header-value")
client, err := cdp.StartWithURL(context.Background(), u, h)
if err != nil {
panic(err)
}
browser := rod.New().Client(client).MustConnect()
browser.MustVersion()
} |
Please fix the format of your markdown: 7 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"] generated by check-issue |
The problem is that following code: res, err := http.Get(toHTTP(*u).String()) //nolint: noctx
if err != nil {
return nil, err
} Is part of the call to https://github.com/go-rod/rod/blob/main/lib/launcher/manager.go#L54 |
I see, then we need a new method to support this requirement. |
Before the new version of rod, you might have to use a proxy to handle the extra http header for your service. |
Rod Version: v0.116.2
The code to demonstrate your question
I currently run headless-browser in google cloud run service using the go-rod image. From other service I connect to it via
What you got
The problem is that this request is executed by default
http.Get
request and it fails because it is not authorized (missing headers). So every call from my other service ends up with 403 when trying to setup the launcher and create a browser.What you expect to see
I would expect to be able to inject a custom http.Client that would handle the authorization.
What have you tried to solve the question
I've tried navigating the code but it seems like the http.Get is hardcoded.
The text was updated successfully, but these errors were encountered: