Skip to content

ui-router-server / connect / createConnectMiddleware

Function: createConnectMiddleware()

ts
function createConnectMiddleware(router, options?): ConnectMiddleware;

Defined in: connect.ts:154

Wraps a ServerRouter as Connect middleware. Mount it BEFORE the static layer; the default host serves shells by rewriting req.url and next()ing into it. resolve() is always async (the simulate tier's lazy boundary), which Connect absorbs naturally — with matcher-tier mounts nothing async ever actually runs.

  • redirectwriteHead(302, { Location }), the request's search MERGED into the verdict's location via mergeSearch (targets that declare their own query keep it — never ?a=1?b=2).
  • shellLink: <mount>; rel="canonical" (the shell is the same representation at every route path), then serveShell.
  • shell with status (the otherwise projection) → validators stripped, downstream status relabeled, no canonical Link (a 404 is not an alternate representation of the mount root), then serveShell.
  • notFound with a mount → serveNotFound (honest 404).
  • notFound without a mount, or a non-navigation request → next().

Parameters

ParameterType
routerServerRouter
optionsConnectAdapterOptions

Returns

ConnectMiddleware