libresilient/plugins/redirect
Michał "rysiek" Woźniak 34b87e5ad2 Rewriting tests into Deno 2023-09-26 20:32:54 +00:00
..
__tests__ Rewriting tests into Deno 2023-09-26 20:32:54 +00:00
README.md documenting plugins (ref. #51) 2022-05-17 23:36:08 +00:00
index.js renaming plugin and test files; plugins are now in individual subdirectories (ref. #50) 2022-05-15 18:53:04 +00:00

README.md

Plugin: redirect

This plugin redirects all requests, using a configured HTTP Status code and message, to URLs in a different domain.

For each request, the plugin removes the scheme and domain components, and appends the rest of the URL with the contents of redirectTo configuration variable. This allows for seamless redirection of all requests for URLs in the original domain to a new location, in case the original domain is expected to be permanently unavailable.

This plugin is, in a way, the last line of defense, and can be configured but not enabled (by setting the enabled configuration flag to false). In case of a permanent problem with the original domain visitors with the Service Worker installed and running can receive a config update via alternative transports that enables this plugin, which in turn redirects them to the new domain of the website.

Configuration

The redirect plugin supports the following configuration options:

  • redirectTo (required)
    A string containing the base URL for all redirectons; should end in "/".

  • redirectStatus (default: 302)

  • redirectStatusText (default: "Found") These two config variables define the HTTP status code and message to be used for the redirect.

  • enabled (default: false)
    If set to false the plugin is disabled, but still loaded into the service worker.
    This is useful if you want to have the redirect plugin loaded and on the ready in case the original website goes completely down. Having the plugin loaded but disabled means that it can be enabled by a configuration change, which can be pushed out even when the original website is not accessible.