@nuiisweety/baileys 0.1.18 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -295,10 +295,25 @@ export async function generateThumbnail(file, mediaType, options) {
295
295
  };
296
296
  }
297
297
  export const getHttpStream = async (url, options = {}) => {
298
- const response = await fetch(url.toString(), {
298
+ const urlStr = url.toString();
299
+ // Auto-inject Referer for domains that require it (e.g. tikwm.com)
300
+ let autoHeaders = {};
301
+ try {
302
+ const parsedUrl = new URL(urlStr);
303
+ const origin = parsedUrl.origin;
304
+ autoHeaders = {
305
+ 'Referer': origin + '/',
306
+ 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36'
307
+ };
308
+ } catch (_) {}
309
+ const mergedHeaders = {
310
+ ...autoHeaders,
311
+ ...(options.headers || {})
312
+ };
313
+ const response = await fetch(urlStr, {
299
314
  dispatcher: options.dispatcher,
300
315
  method: 'GET',
301
- headers: options.headers
316
+ headers: mergedHeaders
302
317
  });
303
318
  if (!response.ok) {
304
319
  throw new Boom(`Failed to fetch stream from ${url}`, { statusCode: response.status, data: { url } });