The incoming HTTP request
The DevtoolsPort instance
Devtools route options including base path and access policy
Response for the matched sub-route
// Next.js catch-all route: app/api/devtools/[[...path]]/route.ts
import { createDevtoolsRoute } from "@beignet/devtools";
import { getServer } from "@/server";
export const { GET, POST } = createDevtoolsRoute(
async () => (await getServer()).ports.devtools,
{
basePath: "/api/devtools",
authorize: async (req) =>
Boolean(await (await getServer()).ports.auth.getSession(req)),
},
);
Unified devtools request handler.
Routes requests to the appropriate handler based on the URL path:
{basePath}/core/events→ event list (GET){basePath}/stream→ live event stream (GET){basePath}/clear→ clear buffer (POST){basePath}→ dashboard UI (GET)This lets you wire up a single catch-all route instead of three separate ones.