Nuxt
The nuxt-auth repo demonstrates Casdoor integration in Nuxt. The flow is similar to the Next.js example.
ステップ1: Casdoorのデプロイ
Deploy Casdoor in production mode. Confirm the login page works (e.g. at http://localhost:8000 with admin / 123 in dev).
Step 2: Add middleware
Create a .js or .ts file in the middleware directory. The filename becomes the middleware name (e.g. myMiddleware.js → myMiddleware). Reference it in nuxt.config.js.
例:
const protectedRoutes = ["/profile"];
export default function ({ route, redirect }) {
if (protectedRoutes.includes(route.path)) {
redirect('/login');
}
}
Enable in nuxt.config.js:
export default {
router: {
middleware: ['myMiddleware'] // your middleware name
},
}
See Nuxt middleware.
ステップ3: Casdoor SDKの使用
Install
npm install casdoor-js-sdk
# or: yarn add casdoor-js-sdk