Skip to content

feat(website): add charset header, integrity attributes, and disable directory indexing#10176

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-default-charset-header
Draft

feat(website): add charset header, integrity attributes, and disable directory indexing#10176
Copilot wants to merge 2 commits intomainfrom
copilot/fix-default-charset-header

Conversation

Copy link
Contributor

Copilot AI commented Mar 27, 2026

Summary

This PR addresses three website security and configuration improvements:

1. Default charset header (utf-8) for all pages

  • Created Astro middleware (website/src/middleware.ts) that sets Content-Type: text/html; charset=utf-8 on all HTML responses
  • The <meta charset="utf-8"> tag was already present in base-layout.astro; the middleware ensures the HTTP header is also set during development and SSR

2. Integrity attribute on /tooling/ page

  • Added integrity="sha384-..." (SRI) attribute to the 1ds-init.js script tag in both:
    • base-layout.astro (used by /tooling/ and other showcase pages)
    • Starlight head config in astro.config.mjs (used by documentation pages)
  • Added crossorigin="anonymous" to the external wcp-consent.js script for proper CORS handling

3. Disable directory indexing for /docs/handbook/configuration/configuration/

  • Added X-Robots-Tag: noindex response header via middleware
  • Added <meta name="robots" content="noindex"> in the page's Starlight frontmatter for static build coverage

Changes

  • website/src/middleware.tsNew file: Astro middleware for charset and directory indexing headers
  • website/src/layouts/base-layout.astro — Added integrity and crossorigin attributes to script tags
  • website/astro.config.mjs — Added integrity and crossorigin to Starlight head script config
  • website/src/content/docs/docs/handbook/configuration/configuration.mdx — Added robots noindex meta tag via frontmatter

Security Summary

  • No security vulnerabilities detected by CodeQL analysis
  • SRI integrity hash computed for 1ds-init.js using SHA-384

Copilot AI and others added 2 commits March 27, 2026 02:36
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta:website TypeSpec.io updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants