Skip to content

Middleware created for redirecting user from /admin to custom page is not working in 4.19.1Version #19425

@RenukaCShekar

Description

@RenukaCShekar

Bug report

Required System information

  • Node.js version: 20.10.0
  • NPM version:10.2.5
  • Strapi version:4.19.1
  • Database:Postgres
  • Operating system:Windows
  • Is your project Javascript or Typescript: Javascript

Describe the bug

Middleware created for redirecting user from /admin to custom page is not working in 4.19.1Version

Steps to reproduce the behavior

  1. Create Middleware for Redirection from /admin to admin/content-manager/collection-types/api::api-name.api-name
  2. Login to /admin using admin/editor credentials
  3. Once we add below code in middleware created for root of library

**'use strict';

/**
redirect` middleware
*/

module.exports = (config, { strapi }) => {
const redirects = ["/", "/index.html", "/admin", "/admin/auth/login"].map((path) => ({
method: "GET",
path,
handler: (ctx) => ctx.redirect("/admin/content-manager/collectionType/api::api-name.api-name"),
config: { auth: false },
}));

strapi.server.routes(redirects);

};**

  1. Successfull login user should get redirected to /admin/content-manager/collectionType/api::api-name.api-name page.

  2. Page is still loading with welcome screen, but when user refreshes the page screen is loading as expected. This is working fine in 4.16.2 version.

Expected behavior

Once user logs in user should see the collection type/ content manager screen as per code in middleware. This is working fine in 4.16.2 version.

Code snippets

'use strict';

/**
redirect` middleware
*/

module.exports = (config, { strapi }) => {
const redirects = ["/", "/index.html", "/admin", "/admin/auth/login"].map((path) => ({
method: "GET",
path,
handler: (ctx) => ctx.redirect("/admin/content-manager/collectionType/api::api-name.api-name"),
config: { auth: false },
}));

strapi.server.routes(redirects);

};

Additional context

This is working fine in 4.16.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    flag: questionAutomation Flag to handle community questions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions