Redirects

Lupus Decoupled Drupal supports CMS-controlled redirects, i.e. Drupal's page API explicitly informs the frontend about redirects to be generated. The frontend, in turn, simply generates the right redirect responses. That way, Drupal-managed redirects just work in the decoupled frontend.

Redirect API responses

The Drupal page API may return data about the page to render OR alternatively a redirect response. A redirect response is formatted like this:

/some-redirected-path
{
      "redirect": {
            "external": false,
            "url": "/new-path",
            "statusCode": 301
      },
      "messages": [ ]

}

In the above example, the frontend would return a HTTP 301 redirect to /new-path when the path /some-redirect-path is requested.

Managing redirects via UI

The Drupal Redirect module provides the ability to create manual redirects and maintains a canonical URL for all content, redirecting all other requests to that path. To use the module with Lupus Decoupled Drupal, simply install and use it - it just works.

Creating redirects via code

Drupal modules may programmatically create redirect responses. To do so, simply return a regular redirect response object from the route, the Lupus CE Renderer module is taking care of converting it to a redirect JSON response when the custom-elements format is requested automatically.