Nelios Redirects v2.0
Nelios Redirects is a Strapi 5 plugin tailored for the CMS5 multisite architecture.
Requirements
- Strapi version >= 5
- SSH access to the frontend repository from the backend server
Setup API Token
Generate a new token from the Strapi dashboard: API Tokens > Create new API Token. Set the type to Custom and the duration to Unlimited, then enable all nelios-redirects permissions only.
Add the token as NELIOS_REDIRECTS_TOKEN in the .env file of cms5-backend (at the root level).
Note: If the token is missing, the plugin will log a warning on startup and redirect syncing will not work.
Adding a New Site
Configure each site by adding its GitHub repository details to the plugin config in the cms5-backend repository:
config/plugins.ts
export default ({
// …other plugins
'nelios-redirects': {
enabled: true,
// resolve: './src/plugins/nelios-redirects',
config: {
api_token: process.env.NELIOS_REDIRECTS_TOKEN,
andronis: {
frontendRepo: 'git@github.com:nelioscom/test-repo-1.git',
frontendBranch: 'main',
targetPath: 'apps/andronis/',
middlewareRedirects: false
},
electra: {
frontendRepo: 'git@github.com:nelioscom/test-repo-1.git',
frontendBranch: 'main',
targetPath: 'apps/electra/',
middlewareRedirects: false
}
}
},
// …other plugins
});Notes
- The key name (e.g.,
andronis) must match the site identifier used by the plugin. - If
middlewareRedirectsis set totrue, additional frontend middleware setup is required (see Prepare the Frontend Repository and Frontend Middleware Setup). This enables support for more than Vercel’s 1,024-redirect limit. - If
middlewareRedirectsisfalse, the plugin will not require or update the middleware-related files (redirects.json,bloom-filter.json).
Prepare the Backend Server
Ensure the backend server has SSH access to the frontend repositories (via an SSH key) so the plugin can read and write the required files.
Prepare the Frontend Repository
Skip this if
middlewareRedirects: false.
Create and initialize the following JSON files (with {}) at the path specified by targetPath.
For example, for the Andronis frontend at /apps/andronis/:
/apps/andronis/bloom-filter.json
/apps/andronis/redirects.jsonInitialize both files with {}.
Frontend Middleware Setup
Skip this if
middlewareRedirects: false.
If a site requires more than 1,024 redirects, set middlewareRedirects: true and add the corresponding middleware to the frontend project.
A resources folder inside this plugin contains the required files and example middleware code you can copy into your frontend to parse redirects.json and apply the rules at the edge.
How It Works
Vercel imposes a hard limit of 1,024 redirects in next.config.js. The plugin:
- Uses Next.js’s built-in
redirects()up to that limit. - Writes any additional rules to a custom
redirects.jsonfile in the target path. - Uses a
bloom-filter.jsonto speed up redirect lookups in middleware whenmiddlewareRedirectsis enabled.