16 lines
602 B
TypeScript
16 lines
602 B
TypeScript
import { runAuthGuard } from "@agent-native/core/server";
|
|||
|
|
/**
|
||
|
|
* Global auth middleware — runs for ALL requests (page routes, API routes,
|
||
|
|
* framework routes). The auth plugin configures the guard; this middleware
|
||
|
|
* enforces it on every request.
|
||
|
|
*
|
||
|
|
* Without this, auth only runs for /_agent-native/* routes because the
|
||
|
|
* framework handler's middleware registry is scoped to that catch-all.
|
||
|
|
* Page routes (/, /settings) and API routes (/api/*) would bypass auth.
|
||
|
|
*/
|
||
|
|
import { defineEventHandler } from "h3";
|
||
|
|
|
||
|
|
export default defineEventHandler(async (event) => {
|
||
|
|
return runAuthGuard(event);
|
||
|
|
});
|