MCPcopy Index your code
hub / github.com/simstudioai/sim / getDefaultHeaders

Function getDefaultHeaders

apps/sim/tools/http/utils.ts:11–41  ·  view source on GitHub ↗
(
  customHeaders: Record<string, string> = {},
  url?: string
)

Source from the content-addressed store, hash-verified

9 * @returns Record of HTTP headers
10 */
11export const getDefaultHeaders = (
12 customHeaders: Record<string, string> = {},
13 url?: string
14): Record<string, string> => {
15 const headers: Record<string, string> = {
16 'User-Agent':
17 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
18 Accept: '*/*',
19 'Accept-Encoding': 'gzip, deflate, br',
20 'Cache-Control': 'no-cache',
21 Connection: 'keep-alive',
22 Referer: getBaseUrl(),
23 'Sec-Ch-Ua': 'Chromium;v=91, Not-A.Brand;v=99',
24 'Sec-Ch-Ua-Mobile': '?0',
25 'Sec-Ch-Ua-Platform': '"macOS"',
26 ...customHeaders,
27 }
28
29 if (url) {
30 try {
31 const hostname = new URL(url).host
32 if (hostname && !customHeaders.Host && !customHeaders.host) {
33 headers.Host = hostname
34 }
35 } catch (_e) {
36 // Invalid URL, will be caught later
37 }
38 }
39
40 return headers
41}
42
43/**
44 * Processes a URL with path parameters and query parameters

Callers 1

request.tsFile · 0.90

Calls 1

getBaseUrlFunction · 0.90

Tested by

no test coverage detected