Spaces:
Runtime error
Runtime error
akashyadav758 Claude Opus 4.8 (1M context) commited on
Commit ·
645c976
1
Parent(s): 321bbb7
Use Linux UA (was macOS) so Cloudflare doesn't flag headless mismatch
Browse filesBrowser ran on Linux but advertised a macOS User-Agent, an inconsistency
Cloudflare Turnstile flags -> infinite verify loop on the ChatGPT site.
Switch all UAs to a Linux Chrome string and align the ChatGPT backend to
Chrome 145 to match the in-browser Chrome for Testing build, so the
cf_clearance cookie (bound to UA) stays valid across browser and backend.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- .gitignore +3 -0
- chatgpt-free-api/cookies.go +2 -2
- free-gemini-api/gemini/client.go +8 -8
- start_hf.sh +1 -1
.gitignore
CHANGED
|
@@ -1,5 +1,8 @@
|
|
| 1 |
# Hugging Face secret token — never commit
|
| 2 |
hf-token
|
| 3 |
|
|
|
|
|
|
|
|
|
|
| 4 |
# Pasted screenshots / scratch images
|
| 5 |
image.png
|
|
|
|
| 1 |
# Hugging Face secret token — never commit
|
| 2 |
hf-token
|
| 3 |
|
| 4 |
+
# Neon Postgres DB credentials (DATABASE_URL) — never commit
|
| 5 |
+
neon-db
|
| 6 |
+
|
| 7 |
# Pasted screenshots / scratch images
|
| 8 |
image.png
|
chatgpt-free-api/cookies.go
CHANGED
|
@@ -153,7 +153,7 @@ func DirectHTTPRequest(method, urlStr string, headers map[string]string, body st
|
|
| 153 |
req.Header.Set("Cookie", GetCachedCookieHeader())
|
| 154 |
|
| 155 |
// Set default headers for ChatGPT
|
| 156 |
-
req.Header.Set("User-Agent", "Mozilla/5.0 (
|
| 157 |
req.Header.Set("Accept", "*/*")
|
| 158 |
req.Header.Set("Accept-Language", "en-US,en;q=0.9")
|
| 159 |
req.Header.Set("Origin", "https://chatgpt.com")
|
|
@@ -448,7 +448,7 @@ func extractConversationID(raw string) string {
|
|
| 448 |
func SolveFNVPow(seed, difficulty string) string {
|
| 449 |
for nonce := 0; nonce < 500000; nonce++ {
|
| 450 |
// Build a config array matching the browser's format
|
| 451 |
-
config := fmt.Sprintf(`[3000,"%s",4294705152,%d,"Mozilla/5.0 (
|
| 452 |
time.Now().String(), nonce, nonce, uuid.NewString(), time.Now().UnixMilli())
|
| 453 |
|
| 454 |
encoded := base64.StdEncoding.EncodeToString([]byte(config))
|
|
|
|
| 153 |
req.Header.Set("Cookie", GetCachedCookieHeader())
|
| 154 |
|
| 155 |
// Set default headers for ChatGPT
|
| 156 |
+
req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36")
|
| 157 |
req.Header.Set("Accept", "*/*")
|
| 158 |
req.Header.Set("Accept-Language", "en-US,en;q=0.9")
|
| 159 |
req.Header.Set("Origin", "https://chatgpt.com")
|
|
|
|
| 448 |
func SolveFNVPow(seed, difficulty string) string {
|
| 449 |
for nonce := 0; nonce < 500000; nonce++ {
|
| 450 |
// Build a config array matching the browser's format
|
| 451 |
+
config := fmt.Sprintf(`[3000,"%s",4294705152,%d,"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36",null,"","en-US","en-US",%d,"hardwareConcurrency−8","location","self",0,"%s","",8,%d]`,
|
| 452 |
time.Now().String(), nonce, nonce, uuid.NewString(), time.Now().UnixMilli())
|
| 453 |
|
| 454 |
encoded := base64.StdEncoding.EncodeToString([]byte(config))
|
free-gemini-api/gemini/client.go
CHANGED
|
@@ -147,7 +147,7 @@ func (c *GeminiClient) InitSession() error {
|
|
| 147 |
return err
|
| 148 |
}
|
| 149 |
|
| 150 |
-
req.Header.Set("User-Agent", "Mozilla/5.0 (
|
| 151 |
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8")
|
| 152 |
req.Header.Set("sec-ch-ua", `"Not(A:Brand";v="8", "Chromium";v="144", "Google Chrome";v="144"`)
|
| 153 |
req.Header.Set("sec-ch-ua-arch", `"arm"`)
|
|
@@ -216,7 +216,7 @@ func (c *GeminiClient) retryInitSession() error {
|
|
| 216 |
return err
|
| 217 |
}
|
| 218 |
|
| 219 |
-
req.Header.Set("User-Agent", "Mozilla/5.0 (
|
| 220 |
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8")
|
| 221 |
req.Header.Set("sec-ch-ua", `"Not(A:Brand";v="8", "Chromium";v="144", "Google Chrome";v="144"`)
|
| 222 |
req.Header.Set("sec-ch-ua-arch", `"arm"`)
|
|
@@ -359,7 +359,7 @@ func (c *GeminiClient) executeStreamRequest(prompt string, onChunk func(text str
|
|
| 359 |
req.URL.RawQuery = q.Encode()
|
| 360 |
|
| 361 |
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
| 362 |
-
req.Header.Set("User-Agent", "Mozilla/5.0 (
|
| 363 |
req.Header.Set("Origin", "https://gemini.google.com")
|
| 364 |
req.Header.Set("Referer", "https://gemini.google.com/")
|
| 365 |
req.Header.Set("X-Same-Domain", "1")
|
|
@@ -458,7 +458,7 @@ func (c *GeminiClient) UploadImage(imageBytes []byte, filename string, mimeType
|
|
| 458 |
req.Header.Set("x-goog-upload-header-content-length", fmt.Sprintf("%d", len(imageBytes)))
|
| 459 |
req.Header.Set("x-goog-upload-header-content-type", mimeType)
|
| 460 |
req.Header.Set("push-id", "feeds/mcudyrk2a4khkz")
|
| 461 |
-
req.Header.Set("User-Agent", "Mozilla/5.0 (
|
| 462 |
req.Header.Set("Origin", "https://gemini.google.com")
|
| 463 |
req.Header.Set("Referer", "https://gemini.google.com/")
|
| 464 |
|
|
@@ -492,7 +492,7 @@ func (c *GeminiClient) UploadImage(imageBytes []byte, filename string, mimeType
|
|
| 492 |
req2.Header.Set("Content-Type", mimeType)
|
| 493 |
req2.Header.Set("Origin", "https://gemini.google.com")
|
| 494 |
req2.Header.Set("Referer", "https://gemini.google.com/")
|
| 495 |
-
req2.Header.Set("User-Agent", "Mozilla/5.0 (
|
| 496 |
|
| 497 |
resp2, err := c.client.Do(req2)
|
| 498 |
if err != nil {
|
|
@@ -819,7 +819,7 @@ func (c *GeminiClient) CallRPC(rpcID, payload string) (string, error) {
|
|
| 819 |
req.URL.RawQuery = q.Encode()
|
| 820 |
|
| 821 |
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
| 822 |
-
req.Header.Set("User-Agent", "Mozilla/5.0 (
|
| 823 |
req.Header.Set("Origin", "https://gemini.google.com")
|
| 824 |
req.Header.Set("Referer", "https://gemini.google.com/")
|
| 825 |
req.Header.Set("X-Same-Domain", "1")
|
|
@@ -881,7 +881,7 @@ func (c *GeminiClient) sendRequest(prompt string, tool string, imageRef []interf
|
|
| 881 |
req.URL.RawQuery = q.Encode()
|
| 882 |
|
| 883 |
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
| 884 |
-
req.Header.Set("User-Agent", "Mozilla/5.0 (
|
| 885 |
req.Header.Set("Origin", "https://gemini.google.com")
|
| 886 |
req.Header.Set("Referer", "https://gemini.google.com/")
|
| 887 |
req.Header.Set("X-Same-Domain", "1")
|
|
@@ -1104,7 +1104,7 @@ func (c *GeminiClient) DownloadFile(urlStr, savePath string) error {
|
|
| 1104 |
return err
|
| 1105 |
}
|
| 1106 |
|
| 1107 |
-
req.Header.Set("User-Agent", "Mozilla/5.0 (
|
| 1108 |
req.Header.Set("Accept", "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8")
|
| 1109 |
req.Header.Set("sec-ch-ua", `"Not(A:Brand";v="8", "Chromium";v="146", "Google Chrome";v="146"`)
|
| 1110 |
req.Header.Set("sec-ch-ua-mobile", "?0")
|
|
|
|
| 147 |
return err
|
| 148 |
}
|
| 149 |
|
| 150 |
+
req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36")
|
| 151 |
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8")
|
| 152 |
req.Header.Set("sec-ch-ua", `"Not(A:Brand";v="8", "Chromium";v="144", "Google Chrome";v="144"`)
|
| 153 |
req.Header.Set("sec-ch-ua-arch", `"arm"`)
|
|
|
|
| 216 |
return err
|
| 217 |
}
|
| 218 |
|
| 219 |
+
req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36")
|
| 220 |
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8")
|
| 221 |
req.Header.Set("sec-ch-ua", `"Not(A:Brand";v="8", "Chromium";v="144", "Google Chrome";v="144"`)
|
| 222 |
req.Header.Set("sec-ch-ua-arch", `"arm"`)
|
|
|
|
| 359 |
req.URL.RawQuery = q.Encode()
|
| 360 |
|
| 361 |
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
| 362 |
+
req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36")
|
| 363 |
req.Header.Set("Origin", "https://gemini.google.com")
|
| 364 |
req.Header.Set("Referer", "https://gemini.google.com/")
|
| 365 |
req.Header.Set("X-Same-Domain", "1")
|
|
|
|
| 458 |
req.Header.Set("x-goog-upload-header-content-length", fmt.Sprintf("%d", len(imageBytes)))
|
| 459 |
req.Header.Set("x-goog-upload-header-content-type", mimeType)
|
| 460 |
req.Header.Set("push-id", "feeds/mcudyrk2a4khkz")
|
| 461 |
+
req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36")
|
| 462 |
req.Header.Set("Origin", "https://gemini.google.com")
|
| 463 |
req.Header.Set("Referer", "https://gemini.google.com/")
|
| 464 |
|
|
|
|
| 492 |
req2.Header.Set("Content-Type", mimeType)
|
| 493 |
req2.Header.Set("Origin", "https://gemini.google.com")
|
| 494 |
req2.Header.Set("Referer", "https://gemini.google.com/")
|
| 495 |
+
req2.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36")
|
| 496 |
|
| 497 |
resp2, err := c.client.Do(req2)
|
| 498 |
if err != nil {
|
|
|
|
| 819 |
req.URL.RawQuery = q.Encode()
|
| 820 |
|
| 821 |
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
| 822 |
+
req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36")
|
| 823 |
req.Header.Set("Origin", "https://gemini.google.com")
|
| 824 |
req.Header.Set("Referer", "https://gemini.google.com/")
|
| 825 |
req.Header.Set("X-Same-Domain", "1")
|
|
|
|
| 881 |
req.URL.RawQuery = q.Encode()
|
| 882 |
|
| 883 |
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
| 884 |
+
req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36")
|
| 885 |
req.Header.Set("Origin", "https://gemini.google.com")
|
| 886 |
req.Header.Set("Referer", "https://gemini.google.com/")
|
| 887 |
req.Header.Set("X-Same-Domain", "1")
|
|
|
|
| 1104 |
return err
|
| 1105 |
}
|
| 1106 |
|
| 1107 |
+
req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36")
|
| 1108 |
req.Header.Set("Accept", "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8")
|
| 1109 |
req.Header.Set("sec-ch-ua", `"Not(A:Brand";v="8", "Chromium";v="146", "Google Chrome";v="146"`)
|
| 1110 |
req.Header.Set("sec-ch-ua-mobile", "?0")
|
start_hf.sh
CHANGED
|
@@ -127,7 +127,7 @@ echo "✨ Launching Chrome Headless..."
|
|
| 127 |
--use-mock-keychain \
|
| 128 |
--password-store=basic \
|
| 129 |
--window-size=980,1070 \
|
| 130 |
-
--user-agent='Mozilla/5.0 (
|
| 131 |
--disable-gpu \
|
| 132 |
--disable-software-rasterizer \
|
| 133 |
--disable-gpu-compositing \
|
|
|
|
| 127 |
--use-mock-keychain \
|
| 128 |
--password-store=basic \
|
| 129 |
--window-size=980,1070 \
|
| 130 |
+
--user-agent='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36' \
|
| 131 |
--disable-gpu \
|
| 132 |
--disable-software-rasterizer \
|
| 133 |
--disable-gpu-compositing \
|