Home / Function/ onRequest() — astro Function Reference

onRequest() — astro Function Reference

Architecture documentation for the onRequest() function in middleware.js from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  435671ea_3da3_b0cb_0334_1ef0f0ee10dd["onRequest()"]
  ad54d829_86c4_9b66_02d7_468a000790cd["middleware.js"]
  435671ea_3da3_b0cb_0334_1ef0f0ee10dd -->|defined in| ad54d829_86c4_9b66_02d7_468a000790cd
  style 435671ea_3da3_b0cb_0334_1ef0f0ee10dd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/test/fixtures/rewrite-custom-404/src/middleware.js lines 3–10

export const onRequest = async (context, next) => {
		if (context.url.pathname.startsWith("/404") || context.url.pathname.startsWith("/500")) {
			Object.assign(context.locals, {
				interjected: "Interjected"
			});
		}
		return  await next();
}

Subdomains

Frequently Asked Questions

What does onRequest() do?
onRequest() is a function in the astro codebase, defined in packages/astro/test/fixtures/rewrite-custom-404/src/middleware.js.
Where is onRequest() defined?
onRequest() is defined in packages/astro/test/fixtures/rewrite-custom-404/src/middleware.js at line 3.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free