MCPcopy Index your code
hub / github.com/FxEmbed/FxEmbed / fetch

Function fetch

src/worker.ts:271–303  ·  view source on GitHub ↗
(request: Request, env: Env, ctx: ExecutionContext)

Source from the content-addressed store, hash-verified

269
270export default {
271 async fetch(request: Request, env: Env, ctx: ExecutionContext) {
272 try {
273 return await app.fetch(request, env, ctx);
274 } catch (err) {
275 console.error(err);
276 const e = err as Error;
277 console.log(`Ouch, that error hurt so much Sentry couldn't catch it`);
278 console.log(e.stack);
279 let errorCode = 500;
280 if (e.name === 'AbortError') {
281 errorCode = 504;
282 }
283 /* We return it as a 200 so embedded applications can display the error */
284 if (request.headers.get('user-agent')?.match(embeddingClientRegex)) {
285 errorCode = 200;
286 }
287 const branding = getBranding(request);
288
289 return new Response(
290 e.name === 'AbortError'
291 ? Strings.TIMEOUT_ERROR_HTML.format({ brandingName: branding.name })
292 : Strings.ERROR_HTML.format({ brandingName: branding.name }),
293 {
294 headers: {
295 ...Constants.RESPONSE_HEADERS,
296 'content-type': 'text/html;charset=utf-8',
297 'cache-control': noCache
298 },
299 status: errorCode
300 }
301 );
302 }
303 }
304};

Callers 15

getCsrfTokenFunction · 0.85
setCountryFunction · 0.85
getSettingsFunction · 0.85
fetchInstagramCsrfTokenFunction · 0.85
fetchInstagramHtmlFunction · 0.85
fetchWebProfileInfoFunction · 0.85
fetchTimelineGraphqlPageFunction · 0.85
fetchCommentPageGraphqlFunction · 0.85
fetchXrpcOnceFunction · 0.85
createSessionFunction · 0.85
refreshSessionFunction · 0.85

Calls 2

getBrandingFunction · 0.90
formatMethod · 0.80

Tested by

no test coverage detected