mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-04 12:33:04 +00:00
17 lines
2.3 KiB
JSON
17 lines
2.3 KiB
JSON
{
|
|
"id": "c00303e3945842923aedef3b",
|
|
"source": "solid:signals",
|
|
"type": "github-document",
|
|
"title": "http-header",
|
|
"content": "---\ntitle: HttpHeader\nuse_cases: \u003e-\n security headers, cors configuration, cache control, seo headers, custom\n headers, api responses\ntags:\n - headers\n - http\n - response\n - security\n - cors\n - meta\nversion: '1.0'\ndescription: \u003e-\n Set custom HTTP headers in SolidStart responses. Configure security, caching,\n CORS, and SEO headers for server-rendered pages.\n---\n\n`HttpHeader` provides a way to set headers on HTTPs response sent by the server.\n\n```tsx\nimport { HttpHeader } from \"@solidjs/start\";\n\n\u003cHttpHeader name=\"x-robots-tag\" value=\"noindex\" /\u003e;\n```\n\n## Setting a header for catch-all routes\n\n```tsx title=\"routes/*404.tsx\"\nimport { HttpHeader, HttpStatusCode } from \"@solidjs/start\";\n\nexport default function NotFound() {\n\treturn (\n\t\t\u003cdiv\u003e\n\t\t\t\u003cHttpStatusCode code={404} /\u003e\n\t\t\t\u003cHttpHeader name=\"my-header\" value=\"header-value\" /\u003e\n\t\t\u003c/div\u003e\n\t);\n}\n```\n\nAs a page is rendered, you may want to add additional HTTP headers to the response and the `HttpHeader` component will do that for you.\nBy passing it a `name` and `value`, they will get added to the `Response` headers sent back to the browser.\n\nWhen streaming responses with [`renderToStream`](/reference/rendering/render-to-stream), HTTP headers can only be added before the stream is first flushed.\nThis requires adding `deferStream` to any resources that need to be loaded before responding.\n\n## Parameters\n\n| Property | Type | Description |\n| -------- | ------ | ------------------------------ |\n| name | string | The name of the header to set |\n| value | string | The value of the header to set |",
|
|
"url": "https://github.com/solidjs/solid-docs/blob/HEAD/src/routes/solid-start/reference/server/http-header.mdx",
|
|
"metadata": {
|
|
"path": "src/routes/solid-start/reference/server/http-header.mdx",
|
|
"repo": "solidjs/solid-docs",
|
|
"repo_url": "https://github.com/solidjs/solid-docs.git",
|
|
"size": 1597,
|
|
"source_type": "github"
|
|
},
|
|
"hash": "37c59f7c8b7dd3a9c66be446888831553072a47fb119ec228cce01f40067b786",
|
|
"timestamp": "2026-02-23T11:43:00.19530883+01:00"
|
|
} |