Skip to content

Commit af4d752

Browse files
committed
fix: headless browser options bug
1 parent 878a359 commit af4d752

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

internal/searchs/browser_support.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ func NewBrowserContextWithOptions(opt BrowserOptions) (playwright.BrowserContext
1818
}
1919

2020
// launch browser
21-
launchOptions := playwright.BrowserTypeLaunchOptions{
22-
Headless: playwright.Bool(false),
23-
}
24-
launchOptions.Headless = playwright.Bool(false)
21+
launchOptions := playwright.BrowserTypeLaunchOptions{}
22+
launchOptions.Headless = playwright.Bool(true)
2523
if opt.ProxyServer != nil && *opt.ProxyServer != "" {
2624
launchOptions.Proxy = &playwright.Proxy{Server: *opt.ProxyServer}
2725
}

internal/searchs/search_text.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ func SearchText(param types.SearchTextPayload) (*types.SearchTextResponse, error
4545
viewportHeight: playwright.Int(1080 - 35),
4646
}
4747
browserCtx, browserClose, err := NewBrowserContextWithOptions(browserOpt)
48-
defer (func() {
49-
_ = browserClose()
50-
})()
5148
if err != nil {
5249
return nil, fmt.Errorf("could not create virtual browser context: %w", err)
5350
}
51+
defer (func() {
52+
_ = browserClose()
53+
})()
5454

5555
// create new page
5656
page, err := browserCtx.NewPage()

0 commit comments

Comments
 (0)