middleware.js — astro Source File
Architecture documentation for middleware.js, a javascript file in the astro codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d313a7b6_b0a2_c5a4_523e_bb8dea1b5f34["middleware.js"] 28099856_58cd_3901_dd91_085b361c6444["astro:i18n"] d313a7b6_b0a2_c5a4_523e_bb8dea1b5f34 --> 28099856_58cd_3901_dd91_085b361c6444 3a7a7ff7_6c64_95f9_af85_4deb518834f1["astro:middleware"] d313a7b6_b0a2_c5a4_523e_bb8dea1b5f34 --> 3a7a7ff7_6c64_95f9_af85_4deb518834f1 style d313a7b6_b0a2_c5a4_523e_bb8dea1b5f34 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { redirectToDefaultLocale, requestHasLocale } from 'astro:i18n';
import { defineMiddleware } from 'astro:middleware';
const allowList = new Set(['/help', '/help/']);
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
Functions
Dependencies
- astro:i18n
- astro:middleware
Source
Frequently Asked Questions
What does middleware.js do?
middleware.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain, SsrAdapters subdomain.
What functions are defined in middleware.js?
middleware.js defines 1 function(s): onRequest.
What does middleware.js depend on?
middleware.js imports 2 module(s): astro:i18n, astro:middleware.
Where is middleware.js in the architecture?
middleware.js is located at packages/astro/test/fixtures/i18n-routing-manual/src/middleware.js (domain: IntegrationAdapters, subdomain: SsrAdapters, directory: packages/astro/test/fixtures/i18n-routing-manual/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free