Home / Function/ createAPIContext() — astro Function Reference

createAPIContext() — astro Function Reference

Architecture documentation for the createAPIContext() function in render-context.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  0acd3c04_45a9_5c6b_ac3e_c0da8b6644c2["createAPIContext()"]
  b7425a46_8c1f_1122_7ae3_a00e52db1d90["RenderContext"]
  0acd3c04_45a9_5c6b_ac3e_c0da8b6644c2 -->|defined in| b7425a46_8c1f_1122_7ae3_a00e52db1d90
  9c5f11d9_36cd_d739_b7da_42358d602de6["render()"]
  9c5f11d9_36cd_d739_b7da_42358d602de6 -->|calls| 0acd3c04_45a9_5c6b_ac3e_c0da8b6644c2
  style 0acd3c04_45a9_5c6b_ac3e_c0da8b6644c2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/render-context.ts lines 351–368

	createAPIContext(props: APIContext['props'], context: ActionAPIContext): APIContext {
		const redirect = (path: string, status = 302) =>
			new Response(null, { status, headers: { Location: path } });

		const rewrite = async (reroutePayload: RewritePayload) => {
			return await this.#executeRewrite(reroutePayload);
		};

		Reflect.set(context, pipelineSymbol, this.pipeline);

		return Object.assign(context, {
			props,
			redirect,
			rewrite,
			getActionResult: createGetActionResult(context.locals),
			callAction: createCallAction(context),
		});
	}

Domain

Subdomains

Called By

Frequently Asked Questions

What does createAPIContext() do?
createAPIContext() is a function in the astro codebase, defined in packages/astro/src/core/render-context.ts.
Where is createAPIContext() defined?
createAPIContext() is defined in packages/astro/src/core/render-context.ts at line 351.
What calls createAPIContext()?
createAPIContext() is called by 1 function(s): render.

Analyze Your Own Codebase

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

Try Supermodel Free