MCPcopy Index your code
hub / github.com/TanStack/router / localFetch

Function localFetch

packages/start-plugin-core/src/prerender.ts:78–98  ·  view source on GitHub ↗
(
    path: string,
    options?: RequestInit,
    maxRedirects: number = 5,
  )

Source from the content-addressed store, hash-verified

76 return res.status >= 300 && res.status < 400 && res.headers.get('location')
77 }
78 async function localFetch(
79 path: string,
80 options?: RequestInit,
81 maxRedirects: number = 5,
82 ): Promise<Response> {
83 const url = new URL(path, baseUrl)
84 const request = new Request(url, options)
85 const response = await fetch(request)
86
87 if (isRedirectResponse(response) && maxRedirects > 0) {
88 const location = response.headers.get('location')!
89 if (location.startsWith('http://localhost') || location.startsWith('/')) {
90 const newUrl = location.replace('http://localhost', '')
91 return localFetch(newUrl, options, maxRedirects - 1)
92 } else {
93 logger.warn(`Skipping redirect to external location: ${location}`)
94 }
95 }
96
97 return response
98 }
99
100 try {
101 // Crawl all pages

Callers 1

addCrawlPageTaskFunction · 0.85

Calls 6

isRedirectResponseFunction · 0.85
startsWithMethod · 0.80
getMethod · 0.65
replaceMethod · 0.65
warnMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected