Skip to content

ui-router-server / fetch / createFetchHandler

Function: createFetchHandler()

ts
function createFetchHandler(router, options): FetchHandler;

Defined in: fetch.ts:145

Wraps a ServerRouter as a WinterCG fetch handler. resolve() is always async (the simulate tier's lazy boundary), which fetch absorbs naturally — with matcher-tier mounts nothing async ever actually runs.

  • redirect -> Response(null, { status, Location }), the request's search MERGED into the location via mergeSearch (targets that declare their own query keep it — never ?a=1?b=2).
  • shell -> serveShell on a Request rewritten to shellPath, the raw asset Response wrapped with a Link: <mount>; rel="canonical" header (the shell is the same representation at every route path).
  • shell with status (the otherwise projection) -> validators stripped, the asset Response's status relabeled to the verdict's, no canonical Link (a 404 is not an alternate representation of the mount root).
  • notFound with a mount -> serveNotFound (honest 404).
  • notFound without a mount, or a non-navigation request -> null (the host serves it however it would have).

Parameters

ParameterType
routerServerRouter
optionsFetchAdapterOptions

Returns

FetchHandler