I have a custom route in express that uses paylaod auth and if the user is logged out it sends them to the
http://localhost:3000/admin/login?redirect=%sFutils%2Fadd-device%2F1234However after login they are redirected to
http://localhost:3000/admin/utils/add-device/1234Is there a way to allow me to redirect to the correct route?
Resolved by switching to a custom view:
https://payloadcms.com/docs/admin/components#viewsCould you share the view you used as an example? I'm working on a similar issue.
My example, which overrides the admin homepage:
payload.config.tsadmin: {
 views: {
        LoginRedirect: {
          Component: LoginRedirect,
          path: '/',
          exact: true
        }
      }
}LoginRedirect.tsximport React from 'react';
import { AdminViewComponent } from 'payload/config'
export const LoginRedirect: AdminViewComponent = (props) => {
  const { user } = props
  switch (user.role) {
    case "admin": {
      window.location.href = '../admin/collections/sessions'
      break;
    }
    // ... other cases for all roles
}
  return <></>
}Star
Discord
online
Get dedicated engineering support directly from the Payload team.