Edit documentation Edit document
SSR/SSG

RedirectsHandler.js

Overview

The RedirectsHandler class is responsible for validating whether a given URL matches any routes configured for redirection. The list of routes is provided during the initialization of the class instance, which occurs for every incoming request.


Content


Methods

checkRedirects

  • Purpose: Checks if url match with redirects "from"

  • Parameters:

    • url: (string): url .
  • Returns: An object contain urls in "from" (string) and "to" (string).

  • Behavior: Checks if url match with redirects "from".


Config structure

Here you can add new redirects or delete existing ones:


export const redirects = [
  {
      from: "/your-website/route/",
      to: "/new/your-website/route/"
  },
    ...
]
Property Name Type Description
from string old route
to string new route

This must be an array of objects, each of which contain from and to properties.