Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): add server.headers typing #5635

Merged
merged 3 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slow-nails-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Add `server.headers` typing
21 changes: 21 additions & 0 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
ShikiConfig,
} from '@astrojs/markdown-remark';
import type * as babel from '@babel/core';
import type { OutgoingHttpHeaders } from 'http';
import type { AddressInfo } from 'net';
import type { TsConfigJson } from 'tsconfig-resolver';
import type * as vite from 'vite';
Expand Down Expand Up @@ -319,6 +320,16 @@ type ServerConfig = {
* If the given port is already in use, Astro will automatically try the next available port.
*/
port?: number;

/**
* @name server.headers
* @typeraw {OutgoingHttpHeaders}
* @default `{}`
* @version 1.7.0
* @description
* Set custom HTTP response headers to be sent in `astro dev` and `astro preview`.
*/
headers?: OutgoingHttpHeaders;
};

export interface ViteUserConfig extends vite.UserConfig {
Expand Down Expand Up @@ -666,6 +677,16 @@ export interface AstroUserConfig {
* ```
*/

/**
* @docs
* @name server.headers
* @typeraw {OutgoingHttpHeaders}
* @default `{}`
* @version 1.7.0
* @description
* Set custom HTTP response headers to be sent in `astro dev` and `astro preview`.
*/

server?: ServerConfig | ((options: { command: 'dev' | 'preview' }) => ServerConfig);

/**
Expand Down