Remove Auth
This page describes how to remove auth for Next JS
Disable Authentication Temporary
Disabling authentication temporarily is generally not recommended due to security risks. However, if you have a specific scenario where you need to disable authentication for a short period, here are some steps you can follow:
Comment out the
AuthGuardwrapper for the routes within theDashboardLayoutelement:
// project-imports
import DashboardLayout from 'layout/DashboardLayout';
// import AuthGuard from 'utils/route-guard/AuthGuard';
// ==============================|| DASHBOARD LAYOUT ||============================== //
export default function Layout({ children }: { children: React.ReactNode }) {
return (
// <AuthGuard>
<DashboardLayout>{children}</DashboardLayout>
// </AuthGuard>
);
}// project-imports
import DashboardLayout from 'layout/DashboardLayout';
// import AuthGuard from 'utils/route-guard/AuthGuard';
// ==============================|| DASHBOARD LAYOUT ||============================== //
export default function Layout({ children }) {
return (
// <AuthGuard>
<DashboardLayout>{children}</DashboardLayout>
// </AuthGuard>
);
}In the code snippet above, the <AuthGuard> a component is commented out, allowing the routes within the DashboardLayoutcomponent to be rendered without authentication protection. To enable the AuthGuard wrapper again, remove the comment markers (//) surrounding the <AuthGuard> component.
Remove Authentication Permanent
If you want to remove authentication from a system or application permanently, here are the steps to follow:
Remove below authentication keys below from
next.config.jsfile.
...
.
NEXT_APP_JWT_SECRET:
NEXT_APP_JWT_TIMEOUT:
NEXTAUTH_SECRET_KEY:
Removed below list of files and directories.
├── src
│ ├── app
│ │ ├── auth (remove directory with all sub files)
│ │ ├── api (remove directory with all sub files)
│ ├── views
│ │ ├── authentication (remove directory with all sub files)
│ │ ├── auth (remove directory with all sub files)
│ ├── sections
│ │ ├── auth (remove directory with all sub files)
│ ├── utils
│ │ ├── route-guard (remove directory with all sub files)
│ │ ├── authOptions.tsCommented out the full file
./src/utils/axios.tsRemove or change
/loginroutes.If you want to remove routes, remove the router component
Linkwithhref=''props.If you want to change url, set the home page URL like,
to={APP_DEFAULT_PATH}, And importAPP_DEFAULT_PATHfromconfigfile.
Last updated