Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23 AS builder
FROM golang:1.24 AS builder

WORKDIR /app
COPY . .
Expand Down
17 changes: 13 additions & 4 deletions utils/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ func GetEnv(name string) (string, error) {
func InitChromeDp() (chromedpCtx context.Context, cancelFnc context.CancelFunc) {
log.Printf("Initializing chromedp...")
if Headless {
chromedpCtx, cancelFnc = chromedp.NewContext(context.Background())
opts := append(chromedp.DefaultExecAllocatorOptions[:],
chromedp.Flag("headless", true),
chromedp.Flag("no-sandbox", true),
chromedp.Flag("disable-dev-shm-usage", true),
chromedp.Flag("disable-gpu", true),
)
allocCtx, _ := chromedp.NewExecAllocator(context.Background(), opts...)
chromedpCtx, cancelFnc = chromedp.NewContext(allocCtx)
} else {
allocCtx, _ := chromedp.NewExecAllocator(context.Background())
chromedpCtx, cancelFnc = chromedp.NewContext(allocCtx)
Expand Down Expand Up @@ -164,10 +171,12 @@ func RefreshAstraToken(chromedpCtx context.Context) map[string][]string {

// Save all cookies to string
cookieStr := ""
_, err = chromedp.RunResponse(chromedpCtx,
chromedp.WaitVisible(`body`, chromedp.ByQuery),
err = chromedp.Run(chromedpCtx,
chromedp.ActionFunc(func(ctx context.Context) error {
cookies, err := network.GetCookies().Do(ctx)
if err != nil {
return err
}
gotToken := false
for _, cookie := range cookies {
cookieStr = fmt.Sprintf("%s%s=%s; ", cookieStr, cookie.Name, cookie.Value)
Expand All @@ -179,7 +188,7 @@ func RefreshAstraToken(chromedpCtx context.Context) map[string][]string {
if !gotToken {
return errors.New("failed to get a new token")
}
return err
return nil
}),
)
if err != nil {
Expand Down
Loading