Skip to content

feat(security): add security response headers - #753

Draft
dgaponov wants to merge 1 commit into
mainfrom
seo/security-headers
Draft

feat(security): add security response headers#753
dgaponov wants to merge 1 commit into
mainfrom
seo/security-headers

Conversation

@dgaponov

@dgaponov dgaponov commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Сайт не отдавал ни одного заголовка безопасности и раскрывал фреймворк через X-Powered-By. Добавлены HSTS, X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy + poweredByHeader: false.

Два отступления от шаблона:

  • X-Frame-Options: SAMEORIGIN, не DENYSandboxBlock встраивает same-origin iframe на каждой странице компонента, DENY сломал бы все демо.
  • HSTS без preload и на год, а не на два: попадание в preload-список необратимо.

⚠️ Перед мержем: стоит includeSubDomains. Если какой-то поддомен отдаётся по HTTP, он станет недоступен, и браузеры запомнят это на год. Скажите — уберу.

CSP не добавлял, ему нужен отдельный allow-list под storage.yandexcloud.net и GTM.

🤖 Generated with Claude Code

The site sent no security headers at all: no HSTS, X-Content-Type-Options,
X-Frame-Options, Referrer-Policy or Permissions-Policy, and it disclosed
its framework via X-Powered-By.

Adds a headers() rule for all routes plus poweredByHeader: false.

Two deliberate deviations from the usual boilerplate:

- X-Frame-Options is SAMEORIGIN, not DENY. SandboxBlock embeds
  `${window.location.origin}/sandbox/<libId>/<componentId>` in an iframe on
  every component page, and DENY blocks same-origin framing too, so DENY
  would break every live component demo.
- HSTS omits `preload`. Submitting to the preload list is effectively
  irreversible, and max-age is 1 year rather than 2. `includeSubDomains` is
  set, which assumes every subdomain is HTTPS-only — verify before deploy.

CSP is not included; it needs its own pass to build an allow-list for
storage.yandexcloud.net and GTM.

Verified in dev and in a production build: all five headers present on
pages and on the sandbox route, X-Powered-By gone everywhere, and the
sandbox iframe still loads and hydrates (checked in a real browser:
contentDocument accessible, no framing errors in console). Build, lint and
typecheck pass. E2E not run — Playwright browsers are not installed locally.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant