feat(website): add charset header, integrity attributes, and disable directory indexing#10176
feat(website): add charset header, integrity attributes, and disable directory indexing#10176
Conversation
…directory indexing - Create Astro middleware to set Content-Type charset=utf-8 for all HTML responses - Add integrity attribute (SHA-384) to 1ds-init.js script in base-layout and Starlight config - Add crossorigin="anonymous" to external wcp-consent.js script - Disable directory indexing for /docs/handbook/configuration/configuration/ via meta robots tag and middleware X-Robots-Tag header Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/7dfd7541-76dc-4f3c-9397-bdedcfaca7a0 Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/7dfd7541-76dc-4f3c-9397-bdedcfaca7a0 Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
|
/azp run typespec - PR Tools |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
No changes needing a change description found. |
|
You can try these changes here
|
|
@copilot this is not emitting charset with the content-type in http response headers. Please see if you can determine why and fix. Once fixed, make sure to merge with the latest from main and verify that all files are correctly formatted |
The charset is communicated through Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Summary
This PR addresses three website security and configuration improvements:
1. Default charset (utf-8) for all pages
<meta charset="utf-8">tag is present in bothbase-layout.astro(for showcase pages like/tooling/) and Starlight's default layout (for docs pages), ensuring browsers interpret all pages as UTF-8website/src/middleware.ts) additionally sets theContent-Type: text/html; charset=utf-8HTTP header during local development (astro dev)Content-Type: text/html; charset=utf-8by default2. Integrity attribute on
/tooling/pageintegrity="sha384-..."(SRI) attribute to the1ds-init.jsscript tag in both:base-layout.astro(used by/tooling/and other showcase pages)astro.config.mjs(used by documentation pages)crossorigin="anonymous"to the externalwcp-consent.jsscript for proper CORS handling3. Disable directory indexing for
/docs/handbook/configuration/configuration/<meta name="robots" content="noindex">in the page's Starlight frontmatter, which is rendered into the static HTML and works on all hosting platformsNote: The Astro middleware sets HTTP headers during local development only. For the static production build, charset and noindex are handled via HTML meta tags, which are effective on all platforms including GitHub Pages and Azure Blob Storage PR previews.
Changes
website/src/middleware.ts— New file: Astro middleware for charset and noindex headers during local developmentwebsite/src/layouts/base-layout.astro— Addedintegrityandcrossoriginattributes to script tagswebsite/astro.config.mjs— Addedintegrityandcrossoriginto Starlight head script configwebsite/src/content/docs/docs/handbook/configuration/configuration.mdx— Added robots noindex meta tag via frontmatterSecurity Summary
1ds-init.jsusing SHA-384⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.