constants.ts — astro Source File
Architecture documentation for constants.ts, a typescript file in the astro codebase.
Entity Profile
Relationship Graph
Source Code
// process.env.PACKAGE_VERSION is injected when we build and publish the astro package.
export const ASTRO_VERSION = process.env.PACKAGE_VERSION ?? 'development';
export const ASTRO_GENERATOR = `Astro v${ASTRO_VERSION}`;
/**
* The name for the header used to help rerouting behavior.
* When set to "no", astro will NOT try to reroute an error response to the corresponding error page, which is the default behavior that can sometimes lead to loops.
*
* ```ts
* const response = new Response("keep this content as-is", {
* status: 404,
* headers: {
* // note that using a variable name as the key of an object needs to be wrapped in square brackets in javascript
* // without them, the header name will be interpreted as "REROUTE_DIRECTIVE_HEADER" instead of "X-Astro-Reroute"
* [REROUTE_DIRECTIVE_HEADER]: 'no',
* }
* })
* ```
* Alternatively...
* ```ts
* response.headers.set(REROUTE_DIRECTIVE_HEADER, 'no');
* ```
*/
export const REROUTE_DIRECTIVE_HEADER = 'X-Astro-Reroute';
/**
* Header and value that are attached to a Response object when a **user rewrite** occurs.
*
* This metadata is used to determine the origin of a Response. If a rewrite has occurred, it should be prioritised over other logic.
*/
export const REWRITE_DIRECTIVE_HEADER_KEY = 'X-Astro-Rewrite';
export const REWRITE_DIRECTIVE_HEADER_VALUE = 'yes';
/**
* This header is set by the no-op Astro middleware.
*/
export const NOOP_MIDDLEWARE_HEADER = 'X-Astro-Noop';
/**
* The name for the header used to help i18n middleware, which only needs to act on "page" and "fallback" route types.
*/
export const ROUTE_TYPE_HEADER = 'X-Astro-Route-Type';
/**
* The value of the `component` field of the default 404 page, which is used when there is no user-provided 404.astro page.
*/
export const DEFAULT_404_COMPONENT = 'astro-default-404.astro';
/**
* A response with one of these status codes will create a redirect response.
*/
export const REDIRECT_STATUS_CODES = [301, 302, 303, 307, 308, 300, 304] as const;
/**
* A response with one of these status codes will be rewritten
* with the result of rendering the respective error page.
*/
export const REROUTABLE_STATUS_CODES = [404, 500];
// ... (73 more lines)
Types
Source
Frequently Asked Questions
What does constants.ts do?
constants.ts is a source file in the astro codebase, written in typescript.
Where is constants.ts in the architecture?
constants.ts is located at packages/astro/src/core/constants.ts (directory: packages/astro/src/core).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free