middleware() — astro Function Reference
Architecture documentation for the middleware() function in i18n.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 3d6f48d1_58f8_07a7_d0a5_56ede30ca4d8["middleware()"] 113cc879_696f_ac71_941f_004a5fb4282c["i18n.ts"] 3d6f48d1_58f8_07a7_d0a5_56ede30ca4d8 -->|defined in| 113cc879_696f_ac71_941f_004a5fb4282c style 3d6f48d1_58f8_07a7_d0a5_56ede30ca4d8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/virtual-modules/i18n.ts lines 392–411
middleware = (customOptions) => {
if (
customOptions.prefixDefaultLocale === false &&
// @ts-expect-error types do not allow this but we also check at runtime
customOptions.redirectToDefaultLocale === true
) {
throw new AstroError(InvalidI18nMiddlewareConfiguration);
}
strategy = toRoutingStrategy(customOptions, {});
fallbackType = toFallbackType(customOptions);
const manifest: SSRManifest['i18n'] = {
...i18n,
strategy,
domainLookupTable: {},
fallbackType,
fallback: i18n.fallback,
domains: i18n.domains,
};
return I18nInternals.createMiddleware(manifest, base, trailingSlash, format);
};
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does middleware() do?
middleware() is a function in the astro codebase, defined in packages/astro/src/virtual-modules/i18n.ts.
Where is middleware() defined?
middleware() is defined in packages/astro/src/virtual-modules/i18n.ts at line 392.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free