onRequest() — astro Function Reference
Architecture documentation for the onRequest() function in middleware.js from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 66b589b2_3c4d_5f3c_0837_74d0c2af4c0c["onRequest()"] d313a7b6_b0a2_c5a4_523e_bb8dea1b5f34["middleware.js"] 66b589b2_3c4d_5f3c_0837_74d0c2af4c0c -->|defined in| d313a7b6_b0a2_c5a4_523e_bb8dea1b5f34 style 66b589b2_3c4d_5f3c_0837_74d0c2af4c0c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/test/fixtures/i18n-routing-manual/src/middleware.js lines 6–20
export const onRequest = defineMiddleware(async (context, next) => {
if (allowList.has(context.url.pathname)) {
return await next();
}
if (requestHasLocale(context)) {
return await next();
}
if (context.url.pathname === '/' || context.url.pathname === '/redirect-me') {
return redirectToDefaultLocale(context);
}
return new Response(null, {
status: 404,
});
});
Domain
Subdomains
Source
Frequently Asked Questions
What does onRequest() do?
onRequest() is a function in the astro codebase, defined in packages/astro/test/fixtures/i18n-routing-manual/src/middleware.js.
Where is onRequest() defined?
onRequest() is defined in packages/astro/test/fixtures/i18n-routing-manual/src/middleware.js at line 6.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free