api/redirect

module:api/redirect

Description:
  • Configuration based request redirection

Source:
Example
api-redirect-login-^/app = ^/login.html?path=@PATH@

api-redirect-url = { "^(app\\.)?host\\.io": "https://app.host.com@PATH@" }
api-redirect-url = { "^/support": "https://myapp.zendesk.com" }

Methods

(static) check(req, nameopt)

Description:
  • Check a request for possible redirection condition based on the configuration. This is used by API servers for early redirections. It returns null if no redirects or errors happend, otherwise an object with status that is expected by the module:api.sendStatus method. uses module:api.checkRedirectPlaceholders for placeholders.

Source:
Parameters:
Name Type Attributes Default Description
req Request

The req.options is expected to contain the following cached request properties:

  • path - from req.path or the request pathname only
  • host - from req.hostname or the hostname part only
  • port - port from the host: header if specified
  • secure - if the protocol is https
name string <optional>
url