Fix fetchLatestWaWebVersion to bypass WhatsApp anti-bot detection with minimal headers (#1883)

* fix: fetchLatestWaWebVersion to curl

* fix: lint

* fix: fetchLatestWaWebVersion to bypass WhatsApp anti-bot detection with minimal headers

---------

Co-authored-by: João Lucas <jlucaso@hotmail.com>
This commit is contained in:
Gustavo Quadri
2025-10-07 14:06:45 -03:00
committed by GitHub
parent 9a8f19461c
commit 60c688b85d
4 changed files with 74 additions and 3 deletions
+12 -2
View File
@@ -274,11 +274,21 @@ export const fetchLatestBaileysVersion = async (options: RequestInit = {}) => {
*/
export const fetchLatestWaWebVersion = async (options: RequestInit = {}) => {
try {
// Absolute minimal headers required to bypass anti-bot detection
const defaultHeaders = {
'sec-fetch-site': 'none',
'user-agent':
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
}
const headers = { ...defaultHeaders, ...options.headers }
const response = await fetch('https://web.whatsapp.com/sw.js', {
dispatcher: options.dispatcher,
...options,
method: 'GET',
headers: options.headers
headers
})
if (!response.ok) {
throw new Boom(`Failed to fetch sw.js: ${response.statusText}`, { statusCode: response.status })
}