Skip to content
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
13 changes: 4 additions & 9 deletions src/content/docs/en/guides/integrations-guide/netlify.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -408,23 +408,19 @@ Injects environment variables from your Netlify site into the development enviro

This allows you to use the same values in development as you would in production. See [the Netlify docs on environment variables](https://docs.netlify.com/build/environment-variables/overview/) for more information, including how to use different variables for different environments.

## Experimental features

The following features are also available for use, but may be subject to breaking changes in future updates. Please follow the [`@astrojs/netlify` CHANGELOG](https://github.com/withastro/astro/tree/main/packages/integrations/netlify/CHANGELOG.md) carefully for updates if you are using these features in your project.

### `experimentalStaticHeaders`
### `staticHeaders`

<p>
**Type:** `boolean` <br />
**Default:** `false`<br />
<Since v="6.4.0" pkg="@astrojs/netlify"/>
<Since v="7.0.0" pkg="@astrojs/netlify"/>
</p>

Enables specifying custom headers for prerendered pages in Netlify's configuration.

If enabled, the adapter will save [static headers in the Framework API config file](https://docs.netlify.com/frameworks-api/#headers) when provided by Astro features, such as Content Security Policy.

For example, when [Content Security Policy](/en/reference/configuration-reference/#securitycsp) is enabled, `experimentalStaticHeaders` can be used to add the CSP `headers` to your Netlify configuration, instead of creating a `<meta>` element:
For example, when [Content Security Policy](/en/reference/configuration-reference/#securitycsp) is enabled, `staticHeaders` can be used to add the CSP `headers` to your Netlify configuration, instead of creating a `<meta>` element:

```js title="astro.config.mjs" {9}
import { defineConfig } from 'astro/config';
Expand All @@ -435,12 +431,11 @@ export default defineConfig({
csp: true
},
adapter: netlify({
experimentalStaticHeaders: true
staticHeaders: true
})
});
```


## Examples

* The [Astro Netlify Edge Starter](https://github.com/sarahetter/astro-netlify-edge-starter) provides an example and a guide in the README.
Expand Down
45 changes: 23 additions & 22 deletions src/content/docs/en/guides/integrations-guide/node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,55 +108,56 @@ export default defineConfig({
});
```

### `experimentalDisableStreaming`
### `staticHeaders`

<p>
**Type:** `boolean` <br />
**Default:** `false`<br />
<Since v="9.3.0" pkg="@astrojs/node" />
**Type:** `boolean` <br />
**Default:** `false`<br />
<Since v="10.0.0" pkg="@astrojs/node"/>
</p>

Disables Astro's default [HTML streaming](/en/guides/on-demand-rendering/#html-streaming) for pages rendered on demand.

HTML streaming helps with performance and generally provides a better visitor experience. In most cases, disabling streaming is not recommended.
If enabled, the adapter will serve the headers of prerendered pages using the `Response` object when provided by Astro features, such as Content Security Policy.

However, when you need to disable HTML streaming (e.g. your host only supports non-streamed HTML caching at the CDN level), you can opt out of the default behavior:
For example, when [Content Security Policy](/en/reference/configuration-reference/#securitycsp) is enabled, `staticHeaders` can be used to add the CSP headers to the `Response` object instead of creating a `<meta>` element:

```js title="astro.config.mjs" {7}
```js title="astro.config.mjs" {10}
import { defineConfig } from 'astro/config';
import node from '@astrojs/node';

export default defineConfig({
security: {
csp: true
},
adapter: node({
mode: 'standalone',
experimentalDisableStreaming: true,
}),
staticHeaders: true,
})
});
```

### `experimentalStaticHeaders`
### `experimentalDisableStreaming`

<p>
**Type:** `boolean` <br />
**Default:** `false`<br />
<Since v="9.3.0" pkg="@astrojs/node"/>
**Type:** `boolean` <br />
**Default:** `false`<br />
<Since v="9.3.0" pkg="@astrojs/node" />
</p>

If enabled, the adapter will serve the headers of prerendered pages using the `Response` object when provided by Astro features, such as Content Security Policy.
Disables Astro's default [HTML streaming](/en/guides/on-demand-rendering/#html-streaming) for pages rendered on demand.

For example, when [Content Security Policy](/en/reference/configuration-reference/#securitycsp) is enabled, `experimentalStaticHeaders` can be used to add the CSP headers to the `Response` object instead of creating a `<meta>` element:
HTML streaming helps with performance and generally provides a better visitor experience. In most cases, disabling streaming is not recommended.

```js title="astro.config.mjs" {10}
However, when you need to disable HTML streaming (e.g. your host only supports non-streamed HTML caching at the CDN level), you can opt out of the default behavior:

```js title="astro.config.mjs" {7}
import { defineConfig } from 'astro/config';
import node from '@astrojs/node';

export default defineConfig({
security csp: true
},
adapter: node({
mode: 'standalone',
experimentalStaticHeaders: true,
})
experimentalDisableStreaming: true,
}),
});
```

Expand Down
61 changes: 29 additions & 32 deletions src/content/docs/en/guides/integrations-guide/vercel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,35 @@ export default defineConfig({
});
```

### `staticHeaders`

<p>
**Type:** `boolean`<br/>
**Default:** `false`<br />
**Available for:** Serverless <br/>
<Since pkg="@astrojs/vercel" v="10.0.0" />
</p>

Enables specifying custom headers for prerendered pages in Vercel's configuration.

If enabled, the adapter will save [static headers in the Vercel `vercel.json` file](https://vercel.com/docs/project-configuration#headers) when provided by Astro features, such as Content Security Policy.

For example, when [Content Security Policy](/en/reference/configuration-reference/#securitycsp) is enabled, `staticHeaders` can be used to add the CSP `headers` to your Vercel configuration, instead of creating a `<meta>` element:

```js title="astro.config.mjs" {9}
import { defineConfig } from 'astro/config';
import vercel from '@astrojs/vercel';

export default defineConfig({
security: {
csp: true
},
adapter: vercel({
staticHeaders: true
})
});
```

### Running Astro middleware on Vercel Edge Functions

The `@astrojs/vercel` adapter can create an [edge function](https://vercel.com/docs/functions/edge-functions) from an Astro middleware in your code base. When `edgeMiddleware` is enabled, an edge function will execute your middleware code for all requests including static assets, prerendered pages, and on-demand rendered pages.
Expand Down Expand Up @@ -503,37 +532,5 @@ The `@astrojs/vercel` adapter supports specific Node.js versions for deploying y

Check out the [Vercel documentation](https://vercel.com/docs/functions/serverless-functions/runtimes/node-js#default-and-available-versions) to learn more.

## Experimental features

The following features are also available for use, but may be subject to breaking changes in future updates. Please follow the [`@astrojs/vercel` CHANGELOG](https://github.com/withastro/astro/tree/main/packages/integrations/vercel/CHANGELOG.md) carefully for updates if you are using these features in your project.

### `experimentalStaticHeaders`

<p>
**Type:** `boolean`<br/>
**Default:** `false`<br />
**Available for:** Serverless <br/>
<Since pkg="@astrojs/vercel" v="8.2.0" />
</p>

Enables specifying custom headers for prerendered pages in Vercel's configuration.

If enabled, the adapter will save [static headers in the Vercel `vercel.json` file](https://vercel.com/docs/project-configuration#headers) when provided by Astro features, such as Content Security Policy.

For example, when [Content Security Policy](/en/reference/configuration-reference/#securitycsp) is enabled, `experimentalStaticHeaders` can be used to add the CSP `headers` to your Vercel configuration, instead of creating a `<meta>` element:

```js title="astro.config.mjs" {9}
import { defineConfig } from 'astro/config';
import vercel from '@astrojs/vercel';

export default defineConfig({
security: {
csp: true
},
adapter: vercel({
experimentalStaticHeaders: true
})
});
```

[astro-integration]: /en/guides/integrations-guide/
6 changes: 3 additions & 3 deletions src/content/docs/en/reference/adapter-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1112,12 +1112,12 @@ export default function createIntegration() {
}
```

### `experimentalStaticHeaders`
### `staticHeaders`

<p>

**Type:** `boolean`<br />
<Since v="5.9.3" />
<Since v="6.0.0" />
</p>

Whether or not the adapter provides experimental support for setting response headers for static pages. When this feature is enabled, Astro will return a map of the `Headers` emitted by the static pages. This map `experimentalRouteToHeaders` is available in the [`astro:build:generated` hook](/en/reference/integrations-reference/#astrobuildgenerated) for generating files such as a `_headers` that allows you to make changes to the default HTTP header.
Expand All @@ -1132,7 +1132,7 @@ export default function createIntegration() {
name: '@example/my-adapter',
serverEntrypoint: '@example/my-adapter/server.js',
adapterFeatures: {
experimentalStaticHeaders: true,
staticHeaders: true,
},
});
},
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/en/reference/integrations-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2404,7 +2404,7 @@ Describes the [Content Security Policy configuration](/en/reference/configuratio
**Type:** `'adapter' | 'meta' | 'header' | undefined`
</p>

Specifies whether CSP directives should be injected as a `meta` element, as a response `header`, or by the [`adapter` when it supports setting response headers](/en/reference/adapter-reference/#experimentalstaticheaders).
Specifies whether CSP directives should be injected as a `meta` element, as a response `header`, or by the [`adapter` when it supports setting response headers](/en/reference/adapter-reference/#staticheaders).

##### `SSRManifest.csp.algorithm`

Expand Down