Home / Function/ onRequest() — astro Function Reference

onRequest() — astro Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  39b2bf6a_c4ba_e13b_57cd_f1939eb16330["onRequest()"]
  bce5c1a2_6c49_6886_1c38_ab3174ea01f7["middleware.ts"]
  39b2bf6a_c4ba_e13b_57cd_f1939eb16330 -->|defined in| bce5c1a2_6c49_6886_1c38_ab3174ea01f7
  style 39b2bf6a_c4ba_e13b_57cd_f1939eb16330 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/test/fixtures/static-redirect/src/middleware.ts lines 3–8

export const onRequest = defineMiddleware(({ isPrerendered }, next) => {
	if (!isPrerendered) {
		throw new Error('This middleware should only run in prerendered mode.');
	}
	return next();
});

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free