Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
fix(docs): serve preload-eligible HSTS so downloads never cross http (#1829)
Andrew Mikofalvyd61fc447f00e
diff --git a/docs/next.config.ts b/docs/next.config.tsindex 1d5d33e4d..5bd385c29 100644--- a/docs/next.config.ts+++ b/docs/next.config.ts@@ -7,6 +7,28 @@ const nextConfig: NextConfig = {// Fail the build on any compiler diagnosticpanicThreshold: 'all_errors',},+ // HSTS with `includeSubDomains; preload` (Vercel's injected default is+ // max-age only). Chrome blocks a download when ANY hop in its redirect+ // chain is plain http — so a visit starting at+ // http://openknowledge.ai/download/beta gets "Insecure download blocked"+ // for the DMG even though Vercel 308s to https immediately. Preload-list+ // membership (hstspreload.org) makes browsers rewrite to https before the+ // first request, removing the http hop entirely; the directives below are+ // the list's eligibility requirements. Subdomain-wide TLS is safe: DNS is+ // a wildcard onto Vercel and every host terminates TLS there.+ async headers() {+ return [+ {+ source: '/:path*',+ headers: [+ {+ key: 'Strict-Transport-Security',+ value: 'max-age=63072000; includeSubDomains; preload',+ },+ ],+ },+ ];+ },// Redirects for deleted docs pages — the prior `Install` page was folded// into Quickstart when the docs pivoted to a desktop-app-first story.async redirects() {diff --git a/docs/src/hsts-header.test.ts b/docs/src/hsts-header.test.tsnew file mode 100644index 000000000..16e839083--- /dev/null+++ b/docs/src/hsts-header.test.ts@@ -0,0 +1,31 @@+import { describe, expect, test } from 'bun:test';+import nextConfig from '../next.config.ts';++describe('Strict-Transport-Security header (hstspreload.org eligibility)', () => {+ async function getStsRule() {+ const rules = (await nextConfig.headers?.()) ?? [];+ for (const rule of rules) {+ const sts = rule.headers.find((h) => h.key.toLowerCase() === 'strict-transport-security');+ if (sts) return { source: rule.source, value: sts.value };+ }+ return null;+ }++ test('header is configured and covers every path including the root', async () => {+ const rule = await getStsRule();+ expect(rule).not.toBeNull();+ expect(rule?.source).toBe('/:path*');+ });++ test('max-age is at least one year (preload-list minimum)', async () => {+ const rule = await getStsRule();+ const maxAge = rule?.value.match(/max-age=(\d+)/)?.[1];+ expect(Number(maxAge)).toBeGreaterThanOrEqual(31536000);+ });++ test('includeSubDomains and preload directives are present', async () => {+ const rule = await getStsRule();+ expect(rule?.value).toContain('includeSubDomains');+ expect(rule?.value).toContain('preload');+ });+});