MCPcopy
hub / github.com/blitz-js/blitz / fetchViaHTTP

Function fetchViaHTTP

integration-tests/utils/next-test-utils.ts:101–118  ·  view source on GitHub ↗
(appPort, pathname, query, opts)

Source from the content-addressed store, hash-verified

99}
100
101export function fetchViaHTTP(appPort, pathname, query, opts) {
102 const url = `${pathname}${
103 typeof query === "string" ? query : query ? `?${qs.stringify(query)}` : ""
104 }`
105 return fetch(getFullUrl(appPort, url), {
106 // in node.js v17 fetch favors IPv6 but Next.js is
107 // listening on IPv4 by default so force IPv4 DNS resolving
108 agent: (parsedUrl) => {
109 if (parsedUrl.protocol === "https:") {
110 return new https.Agent({family: 4})
111 }
112 if (parsedUrl.protocol === "http:") {
113 return new http.Agent({family: 4})
114 }
115 },
116 ...opts,
117 })
118}
119
120export function findPort() {
121 return getPort()

Callers 4

runTestsFunction · 0.90
runTestsFunction · 0.90
runTestsFunction · 0.90
renderViaHTTPFunction · 0.85

Calls 1

getFullUrlFunction · 0.85

Tested by 3

runTestsFunction · 0.72
runTestsFunction · 0.72
runTestsFunction · 0.72