:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
refactor(oauth-proxy): improve region picker page accessibility, caching, and HTML semantics (#64159)
Rafael Audibert84c406168066
diff --git a/services/oauth-proxy/src/handlers/authorize.ts b/services/oauth-proxy/src/handlers/authorize.tsindex e4bece3165c8..4bac80a0275c 100644--- a/services/oauth-proxy/src/handlers/authorize.ts+++ b/services/oauth-proxy/src/handlers/authorize.ts@@ -3,6 +3,15 @@ import { type ClientMapping, getClientMapping, putCallbackRedirectUri, putRegionimport REGION_PICKER_HTML from '../static/region-picker.html'+const REGION_PICKER_HEADERS: Record<string, string> = {+ 'Content-Type': 'text/html; charset=utf-8',+ // Bundled at deploy time; identical for all OAuth flows until the next deploy.+ 'Cache-Control': 'public, max-age=3600, s-maxage=86400, stale-while-revalidate=604800',+ 'X-Frame-Options': 'DENY',+ 'X-Content-Type-Options': 'nosniff',+ 'Referrer-Policy': 'no-referrer',+}+/*** OAuth Authorization — region picker + redirect.*@@ -23,14 +32,7 @@ export async function handleAuthorize(request: Request, kv: KVNamespace): Promis}// Show the region picker page (JS reads query params from window.location.search)- return new Response(REGION_PICKER_HTML, {- headers: {- 'Content-Type': 'text/html; charset=utf-8',- 'X-Frame-Options': 'DENY',- 'X-Content-Type-Options': 'nosniff',- 'Referrer-Policy': 'no-referrer',- },- })+ return new Response(REGION_PICKER_HTML, { headers: REGION_PICKER_HEADERS })}async function redirectToRegionalAuthorize(url: URL, region: Region, kv: KVNamespace): Promise<Response> {diff --git a/services/oauth-proxy/src/static/region-picker.html b/services/oauth-proxy/src/static/region-picker.htmlindex 088fa8dc4369..b51e8fc2a842 100644--- a/services/oauth-proxy/src/static/region-picker.html+++ b/services/oauth-proxy/src/static/region-picker.html@@ -1,15 +1,20 @@<!DOCTYPE html><html lang="en">+<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">- <title>Log in to PostHog</title>+ <meta name="robots" content="noindex, nofollow">+ <title>Authenticate with PostHog</title><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">+<style>:root {--brand-blue: #1d4aff;+ --brand-yellow: #f9bd2b;+ --brand-orange: #f54e00;--text-primary: #111;--text-secondary: #5e5e5e;--bg: #f3f0ec;@@ -21,7 +26,11 @@--button-frame: #eb9d2a;}- * { margin: 0; padding: 0; box-sizing: border-box; }+ * {+ margin: 0;+ padding: 0;+ box-sizing: border-box;+ }body {font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;@@ -35,71 +44,48 @@-webkit-font-smoothing: antialiased;}- .container {+ main {max-width: 520px;width: 100%;}- .window {+ main>article {border: 1px solid var(--border);border-radius: var(--radius);overflow: hidden;+ background: var(--bg-card);+ padding: 48px 40px;+ text-align: center;}- .window-titlebar {- display: flex;+ header {+ display: inline-flex;align-items: center;- justify-content: space-between;- background: var(--bg);- border-bottom: 1px solid var(--border);- padding: 8px 12px;+ gap: 10px;+ margin-bottom: 28px;}- .window-titlebar-left {- display: flex;- align-items: center;- gap: 6px;- color: var(--text-secondary);+ header svg {+ height: 28px;+ width: auto;}- .window-titlebar-left svg { width: 14px; height: 14px; }- .window-titlebar-left .chevron { width: 10px; height: 10px; }-- .window-title {- font-size: 12px;- font-weight: 500;- color: var(--text-secondary);- display: flex;- align-items: center;- gap: 4px;+ .logo-fill-blue {+ fill: var(--brand-blue);}- .window-title .chevron { width: 10px; height: 10px; color: var(--text-secondary); }-- .window-controls {- display: flex;- align-items: center;- gap: 10px;- color: var(--text-secondary);+ .logo-fill-yellow {+ fill: var(--brand-yellow);}- .window-controls svg { width: 14px; height: 14px; }-- .card {- background: var(--bg-card);- padding: 48px 40px;- text-align: center;+ .logo-fill-orange {+ fill: var(--brand-orange);}- .logo-row {- display: inline-flex;- align-items: center;- gap: 10px;- margin-bottom: 28px;+ .logo-fill-text {+ fill: var(--text-primary);}- .logo-row svg { height: 28px; width: auto; }-h1 {font-size: 22px;font-weight: 600;@@ -108,20 +94,25 @@color: var(--text-primary);}- .description {+ h1+p {font-size: 15px;line-height: 1.6;color: var(--text-secondary);margin-bottom: 32px;}- .buttons {+ nav {display: flex;gap: 12px;justify-content: center;}- .cta {+ nav span[aria-hidden="true"] {+ font-size: 18px;+ }++ nav a,+ #redirect-go-now {position: relative;display: inline-flex;align-items: center;@@ -141,46 +132,60 @@transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;}- .cta:hover {+ nav a:hover,+ #redirect-go-now:hover {border-color: var(--button-border-hover);transform: translateY(-0.5px);box-shadow: 0 3.5px 0 -1px var(--button-frame);}- .cta:active {+ nav a:active,+ #redirect-go-now:active {transform: translateY(0.5px);box-shadow: 0 2.5px 0 -1px var(--button-frame);}- .cta svg { width: 16px; height: 16px; }+ nav a:focus-visible,+ button:focus-visible,+ #redirect-go-now:focus-visible {+ outline: 2px solid var(--brand-blue);+ outline-offset: 2px;+ }- .hint {+ noscript p,+ #hint-default {margin-top: 24px;font-size: 13px;color: var(--text-secondary);}- .hint a {+ noscript p a,+ #hint-default a {color: var(--text-secondary);text-decoration: underline;text-underline-offset: 2px;}- .hint a:hover { color: var(--text-primary); }+ noscript p a:hover,+ #hint-default a:hover {+ color: var(--text-primary);+ }- .redirect-banner {+ #redirect-banner {margin-top: 28px;padding: 16px 20px;- background: #f3f0ec;+ background: var(--bg);border-radius: var(--radius);font-size: 14px;color: var(--text-primary);line-height: 1.5;}- .redirect-banner .region-name { font-weight: 600; }+ #redirect-region-name {+ font-weight: 600;+ }- .progress-bar {+ #progress-bar {width: 100%;height: 4px;background: var(--border);@@ -189,7 +194,7 @@overflow: hidden;}- .progress-bar-fill {+ #progress-fill {height: 100%;background: var(--brand-blue);border-radius: 2px;@@ -197,7 +202,7 @@transition: width 100ms linear;}- .redirect-actions {+ #redirect-banner>div:has(> button) {display: flex;align-items: center;justify-content: center;@@ -205,7 +210,7 @@margin-top: 14px;}- .btn-secondary {+ button {display: inline-flex;align-items: center;background: transparent;@@ -214,92 +219,161 @@font-size: 0.8125rem;font-weight: 500;line-height: 1.5rem;- text-decoration: none;padding: 6px 14px;border: 1px solid var(--border);border-radius: var(--radius);cursor: pointer;transition: border-color 200ms ease;+ appearance: none;+ margin: 0;}- .btn-secondary:hover { border-color: var(--text-secondary); }+ button:hover {+ border-color: var(--text-secondary);+ }- .footer {+ footer {text-align: center;margin-top: 20px;font-size: 13px;color: var(--text-secondary);}- .footer a {+ footer a {color: var(--text-secondary);text-decoration: underline;text-underline-offset: 2px;}- .footer a:hover { color: var(--text-primary); }- </style>-</head>-<body>- <div class="container">- <div class="window">- <div class="window-titlebar">- <div class="window-titlebar-left">- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M16.5 10.5V6.75a4.5 4.5 0 1 0-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H6.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25Z"/></svg>- <svg class="chevron" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5"/></svg>- </div>- <span class="window-title">- oauth.posthog.com- <svg class="chevron" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5"/></svg>- </span>- <div class="window-controls">- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M5 12h14"/></svg>- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><rect x="4.5" y="4.5" width="15" height="15" rx="1.5"/></svg>- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12"/></svg>- </div>- </div>- <div class="card">- <div class="logo-row">- <svg fill="none" height="30" viewBox="0 0 157 30" xmlns="http://www.w3.org/2000/svg"><clipPath id="a"><path d="m0 0h157v30h-157z"/></clipPath><g clip-path="url(#a)"><path d="m10.8914 17.2058c-.3685.7371-1.42034.7371-1.78887 0l-.88136-1.7627c-.14077-.2815-.14077-.6129 0-.8944l.88136-1.7628c.36853-.737 1.42037-.737 1.78887 0l.8814 1.7628c.1407.2815.1407.6129 0 .8944z" fill="#1d4aff"/><path d="m10.8914 27.2029c-.3685.737-1.42034.737-1.78887 0l-.88136-1.7627c-.14077-.2816-.14077-.6129 0-.8945l.88136-1.7627c.36853-.7371 1.42037-.7371 1.78887 0l.8814 1.7627c.1407.2816.1407.6129 0 .8945z" fill="#1d4aff"/><path d="m0 23.4082c0-.8909 1.07714-1.3371 1.70711-.7071l4.58338 4.5834c.62997.63.1838 1.7071-.7071 1.7071h-4.583391c-.552284 0-.999999-.4477-.999999-1zm0-4.8278c0 .2652.105357.5196.292893.7071l9.411217 9.4112c.18753.1875.44189.2929.70709.2929h5.1692c.8909 0 1.3371-1.0771.7071-1.7071l-14.58039-14.5804c-.62997-.63-1.70711-.1838-1.70711.7071zm0-9.99701c0 .26521.105357.51957.292893.7071l19.408207 19.40821c.1875.1875.4419.2929.7071.2929h5.1692c.8909 0 1.3371-1.0771.7071-1.7071l-24.57739-24.57739c-.62996-.62996-1.70711-.1838-1.70711.7071zm9.997 0c0 .26521.1054.51957.2929.7071l17.994 17.99401c.63.63 1.7071.1838 1.7071-.7071v-5.1692c0-.2652-.1054-.5196-.2929-.7071l-17.994-17.994c-.63-.62996-1.7071-.18379-1.7071.70711zm11.7041-5.87628c-.63-.62997-1.7071-.1838-1.7071.7071v5.16918c0 .26521.1054.51957.2929.7071l7.997 7.99701c.63.63 1.7071.1838 1.7071-.7071v-5.1692c0-.2652-.1054-.5196-.2929-.7071z" fill="#f9bd2b"/><path d="m42.5249 23.531-9.4128-9.4128c-.6299-.6299-1.7071-.1838-1.7071.7071v13.1665c0 .5522.4477 1 1 1h14.5807c.5522 0 1-.4478 1-1v-1.1991c0-.5523-.4496-.9933-.9973-1.0646-1.6808-.2188-3.2528-.9864-4.4635-2.1971zm-6.3213 2.2617c-.8829 0-1.5995-.7166-1.5995-1.5995s.7166-1.5995 1.5995-1.5995 1.5995.7166 1.5995 1.5995-.7166 1.5995-1.5995 1.5995z" fill="#111"/><path d="m0 27.9917c0 .5523.447715 1 1 1h4.58339c.8909 0 1.33707-1.0771.70711-1.7071l-4.58339-4.5834c-.62997-.6299-1.70711-.1838-1.70711.7072z" fill="#1d4aff"/><path d="m9.997 10.997-8.28989-8.28989c-.62997-.62997-1.70711-.1838-1.70711.7071v5.16918c0 .26521.105357.51957.292893.7071l9.704107 9.70411z" fill="#1d4aff"/><path d="m1.70711 12.7042c-.62997-.63-1.70711-.1838-1.70711.7071v5.1692c0 .2652.105357.5195.292893.7071l9.704107 9.7041v-7.9976z" fill="#1d4aff"/><path d="m19.9939 11.4112c0-.2652-.1053-.5196-.2928-.7071l-7.997-7.99699c-.63-.62997-1.70715-.1838-1.70715.7071v5.16918c0 .26521.10535.51957.29285.7071l9.7041 9.70411z" fill="#f54e00"/><path d="m9.99707 28.9917h5.58343c.8909 0 1.337-1.0771.7071-1.7071l-6.29053-6.2905z" fill="#f54e00"/><path d="m9.99707 10.9971v7.5834c0 .2652.10533.5195.29293.7071l9.7041 9.7041v-7.5834c0-.2652-.1054-.5196-.2929-.7071z" fill="#f54e00"/><g fill="#111"><path d="m59.6497 24.9998h4.108v-6.812h3.432c3.77 0 6.188-2.236 6.188-5.694 0-3.45799-2.418-5.694-6.188-5.694h-7.54zm4.108-10.322v-4.368h3.016c1.56 0 2.496.832 2.496 2.184s-.936 2.184-2.496 2.184z"/><path d="m80.8096 25.2078c4.004 0 6.916-2.86 6.916-6.76s-2.912-6.76-6.916-6.76c-4.056 0-6.916 2.86-6.916 6.76s2.86 6.76 6.916 6.76zm-3.12-6.76c0-2.08 1.248-3.51 3.12-3.51 1.846 0 3.094 1.43 3.094 3.51s-1.248 3.51-3.094 3.51c-1.872 0-3.12-1.43-3.12-3.51z"/><path d="m94.2995 25.2078c3.068 0 5.148-1.924 5.148-4.186 0-5.304-7.046-3.588-7.046-5.668 0-.572.598-.936 1.456-.936.884 0 1.95.546 2.288 1.742l3.068-1.274c-.598-1.898-2.808-3.198-5.486-3.198-2.886 0-4.68 1.716-4.68 3.77 0 4.966 6.942 3.588 6.942 5.642 0 .728-.676 1.222-1.69 1.222-1.456 0-2.47-1.014-2.782-2.236l-3.068 1.196c.676 1.976 2.652 3.926 5.85 3.926z"/><path d="m109.33 24.8698-.26-3.302c-.442.234-1.014.312-1.482.312-.936 0-1.56-.676-1.56-1.846v-4.966h3.172v-3.172h-3.172v-3.796h-3.822v3.796h-2.08v3.172h2.08v5.46c0 3.172 2.158 4.68 4.992 4.68.78 0 1.508-.13 2.132-.338z"/><path d="m122.656 6.7998v7.072h-7.228v-7.072h-4.108v18.2h4.108v-7.618h7.228v7.618h4.134v-18.2z"/><path d="m135.908 25.2078c4.004 0 6.916-2.86 6.916-6.76s-2.912-6.76-6.916-6.76c-4.056 0-6.916 2.86-6.916 6.76s2.86 6.76 6.916 6.76zm-3.12-6.76c0-2.08 1.248-3.51 3.12-3.51 1.846 0 3.094 1.43 3.094 3.51s-1.248 3.51-3.094 3.51c-1.872 0-3.12-1.43-3.12-3.51z"/><path d="m150.201 24.5838c1.43 0 2.704-.494 3.38-1.352v1.248c0 1.456-1.17 2.47-2.964 2.47-1.274 0-2.392-.624-2.574-1.69l-3.484.546c.468 2.47 2.99 4.134 6.058 4.134 4.03 0 6.708-2.366 6.708-5.876v-12.168h-3.77v1.118c-.702-.806-1.898-1.326-3.432-1.326-3.64 0-5.928 2.496-5.928 6.448s2.288 6.448 6.006 6.448zm-2.288-6.448c0-1.95 1.144-3.198 2.912-3.198 1.794 0 2.938 1.248 2.938 3.198s-1.144 3.198-2.938 3.198c-1.768 0-2.912-1.248-2.912-3.198z"/></g></g></svg>- </div>+ footer a:hover {+ color: var(--text-primary);+ }- <h1>Log in to PostHog</h1>+ @media (prefers-reduced-motion: reduce) {- <p class="description">Where is your PostHog project hosted?</p>+ nav a,+ #redirect-go-now,+ #progress-fill {+ transition: none;+ }- <div class="buttons">- <a class="cta" id="btn-us" href="#">- <span style="font-size: 18px">🇺🇸</span>- US Cloud- </a>- <a class="cta" id="btn-eu" href="#">- <span style="font-size: 18px">🇪🇺</span>- EU Cloud- </a>- </div>+ nav a:hover,+ nav a:active,+ #redirect-go-now:hover,+ #redirect-go-now:active {+ transform: none;+ }+ }+ </style>+</head>- <p class="hint" id="hint-default">- Not sure? Check your PostHog URL. It starts with- <a href="https://us.posthog.com" target="_blank">us.</a> or- <a href="https://eu.posthog.com" target="_blank">eu.</a>+<body>+ <main>+ <article>+ <header>+ <svg aria-hidden="true" fill="none" height="30" viewBox="0 0 157 30" xmlns="http://www.w3.org/2000/svg">+ <clipPath id="a">+ <path d="m0 0h157v30h-157z" />+ </clipPath>+ <g clip-path="url(#a)">+ <path+ d="m10.8914 17.2058c-.3685.7371-1.42034.7371-1.78887 0l-.88136-1.7627c-.14077-.2815-.14077-.6129 0-.8944l.88136-1.7628c.36853-.737 1.42037-.737 1.78887 0l.8814 1.7628c.1407.2815.1407.6129 0 .8944z"+ class="logo-fill-blue" />+ <path+ d="m10.8914 27.2029c-.3685.737-1.42034.737-1.78887 0l-.88136-1.7627c-.14077-.2816-.14077-.6129 0-.8945l.88136-1.7627c.36853-.7371 1.42037-.7371 1.78887 0l.8814 1.7627c.1407.2816.1407.6129 0 .8945z"+ class="logo-fill-blue" />+ <path+ d="m0 23.4082c0-.8909 1.07714-1.3371 1.70711-.7071l4.58338 4.5834c.62997.63.1838 1.7071-.7071 1.7071h-4.583391c-.552284 0-.999999-.4477-.999999-1zm0-4.8278c0 .2652.105357.5196.292893.7071l9.411217 9.4112c.18753.1875.44189.2929.70709.2929h5.1692c.8909 0 1.3371-1.0771.7071-1.7071l-14.58039-14.5804c-.62997-.63-1.70711-.1838-1.70711.7071zm0-9.99701c0 .26521.105357.51957.292893.7071l19.408207 19.40821c.1875.1875.4419.2929.7071.2929h5.1692c.8909 0 1.3371-1.0771.7071-1.7071l-24.57739-24.57739c-.62996-.62996-1.70711-.1838-1.70711.7071zm9.997 0c0 .26521.1054.51957.2929.7071l17.994 17.99401c.63.63 1.7071.1838 1.7071-.7071v-5.1692c0-.2652-.1054-.5196-.2929-.7071l-17.994-17.994c-.63-.62996-1.7071-.18379-1.7071.70711zm11.7041-5.87628c-.63-.62997-1.7071-.1838-1.7071.7071v5.16918c0 .26521.1054.51957.2929.7071l7.997 7.99701c.63.63 1.7071.1838 1.7071-.7071v-5.1692c0-.2652-.1054-.5196-.2929-.7071z"+ class="logo-fill-yellow" />+ <path+ d="m42.5249 23.531-9.4128-9.4128c-.6299-.6299-1.7071-.1838-1.7071.7071v13.1665c0 .5522.4477 1 1 1h14.5807c.5522 0 1-.4478 1-1v-1.1991c0-.5523-.4496-.9933-.9973-1.0646-1.6808-.2188-3.2528-.9864-4.4635-2.1971zm-6.3213 2.2617c-.8829 0-1.5995-.7166-1.5995-1.5995s.7166-1.5995 1.5995-1.5995 1.5995.7166 1.5995 1.5995-.7166 1.5995-1.5995 1.5995z"+ class="logo-fill-text" />+ <path+ d="m0 27.9917c0 .5523.447715 1 1 1h4.58339c.8909 0 1.33707-1.0771.70711-1.7071l-4.58339-4.5834c-.62997-.6299-1.70711-.1838-1.70711.7072z"+ class="logo-fill-blue" />+ <path+ d="m9.997 10.997-8.28989-8.28989c-.62997-.62997-1.70711-.1838-1.70711.7071v5.16918c0 .26521.105357.51957.292893.7071l9.704107 9.70411z"+ class="logo-fill-blue" />+ <path+ d="m1.70711 12.7042c-.62997-.63-1.70711-.1838-1.70711.7071v5.1692c0 .2652.105357.5195.292893.7071l9.704107 9.7041v-7.9976z"+ class="logo-fill-blue" />+ <path+ d="m19.9939 11.4112c0-.2652-.1053-.5196-.2928-.7071l-7.997-7.99699c-.63-.62997-1.70715-.1838-1.70715.7071v5.16918c0 .26521.10535.51957.29285.7071l9.7041 9.70411z"+ class="logo-fill-orange" />+ <path d="m9.99707 28.9917h5.58343c.8909 0 1.337-1.0771.7071-1.7071l-6.29053-6.2905z"+ class="logo-fill-orange" />+ <path+ d="m9.99707 10.9971v7.5834c0 .2652.10533.5195.29293.7071l9.7041 9.7041v-7.5834c0-.2652-.1054-.5196-.2929-.7071z"+ class="logo-fill-orange" />+ <g class="logo-fill-text">+ <path+ d="m59.6497 24.9998h4.108v-6.812h3.432c3.77 0 6.188-2.236 6.188-5.694 0-3.45799-2.418-5.694-6.188-5.694h-7.54zm4.108-10.322v-4.368h3.016c1.56 0 2.496.832 2.496 2.184s-.936 2.184-2.496 2.184z" />+ <path+ d="m80.8096 25.2078c4.004 0 6.916-2.86 6.916-6.76s-2.912-6.76-6.916-6.76c-4.056 0-6.916 2.86-6.916 6.76s2.86 6.76 6.916 6.76zm-3.12-6.76c0-2.08 1.248-3.51 3.12-3.51 1.846 0 3.094 1.43 3.094 3.51s-1.248 3.51-3.094 3.51c-1.872 0-3.12-1.43-3.12-3.51z" />+ <path+ d="m94.2995 25.2078c3.068 0 5.148-1.924 5.148-4.186 0-5.304-7.046-3.588-7.046-5.668 0-.572.598-.936 1.456-.936.884 0 1.95.546 2.288 1.742l3.068-1.274c-.598-1.898-2.808-3.198-5.486-3.198-2.886 0-4.68 1.716-4.68 3.77 0 4.966 6.942 3.588 6.942 5.642 0 .728-.676 1.222-1.69 1.222-1.456 0-2.47-1.014-2.782-2.236l-3.068 1.196c.676 1.976 2.652 3.926 5.85 3.926z" />+ <path+ d="m109.33 24.8698-.26-3.302c-.442.234-1.014.312-1.482.312-.936 0-1.56-.676-1.56-1.846v-4.966h3.172v-3.172h-3.172v-3.796h-3.822v3.796h-2.08v3.172h2.08v5.46c0 3.172 2.158 4.68 4.992 4.68.78 0 1.508-.13 2.132-.338z" />+ <path+ d="m122.656 6.7998v7.072h-7.228v-7.072h-4.108v18.2h4.108v-7.618h7.228v7.618h4.134v-18.2z" />+ <path+ d="m135.908 25.2078c4.004 0 6.916-2.86 6.916-6.76s-2.912-6.76-6.916-6.76c-4.056 0-6.916 2.86-6.916 6.76s2.86 6.76 6.916 6.76zm-3.12-6.76c0-2.08 1.248-3.51 3.12-3.51 1.846 0 3.094 1.43 3.094 3.51s-1.248 3.51-3.094 3.51c-1.872 0-3.12-1.43-3.12-3.51z" />+ <path+ d="m150.201 24.5838c1.43 0 2.704-.494 3.38-1.352v1.248c0 1.456-1.17 2.47-2.964 2.47-1.274 0-2.392-.624-2.574-1.69l-3.484.546c.468 2.47 2.99 4.134 6.058 4.134 4.03 0 6.708-2.366 6.708-5.876v-12.168h-3.77v1.118c-.702-.806-1.898-1.326-3.432-1.326-3.64 0-5.928 2.496-5.928 6.448s2.288 6.448 6.006 6.448zm-2.288-6.448c0-1.95 1.144-3.198 2.912-3.198 1.794 0 2.938 1.248 2.938 3.198s-1.144 3.198-2.938 3.198c-1.768 0-2.912-1.248-2.912-3.198z" />+ </g>+ </g>+ </svg>+ </header>++ <h1>Authenticate with PostHog</h1>++ <p>Where is your PostHog project hosted?</p>++ <nav aria-label="Select PostHog region">+ <a id="btn-us" href="#">+ <span aria-hidden="true">🇺🇸</span>+ US Cloud+ </a>+ <a id="btn-eu" href="#">+ <span aria-hidden="true">🇪🇺</span>+ EU Cloud+ </a>+ </nav>++ <noscript>+ <p>Enable JavaScript to continue. Your OAuth login parameters are required from this page.</p>-- <div class="redirect-banner" id="redirect-banner" style="display: none">- <span>You last logged in on <span class="region-name" id="redirect-region-name"></span>. Redirecting in <span id="redirect-countdown">7</span>s...</span>- <div class="progress-bar"><div class="progress-bar-fill" id="progress-fill"></div></div>- <div class="redirect-actions">- <a class="btn-secondary" id="redirect-cancel">Cancel redirect</a>- <a class="cta" id="redirect-go-now"></a>- </div>+ </noscript>++ <p id="hint-default">+ Not sure? Check your PostHog URL. <br />+ It should be either+ <a href="https://us.posthog.com" rel="noopener noreferrer" target="_blank">us.posthog.com</a> or+ <a href="https://eu.posthog.com" rel="noopener noreferrer" target="_blank">eu.posthog.com</a>+ </p>++ <div aria-live="polite" hidden id="redirect-banner">+ <span>You last logged in on <span id="redirect-region-name"></span>. Redirecting+ in <span id="redirect-countdown">7</span>s...</span>+ <div aria-label="Redirect countdown" aria-valuemax="100" aria-valuemin="0" aria-valuenow="0"+ id="progress-bar" role="progressbar">+ <div id="progress-fill"></div>+ </div>+ <div>+ <button id="redirect-cancel" type="button">Cancel redirect</button>+ <a id="redirect-go-now"></a></div></div>- </div>+ </article>- <p class="footer">- © 2026 <a href="https://posthog.com">posthog.com</a>- </p>- </div>+ <footer>+ © <span id="year"></span> <a href="https://posthog.com">posthog.com</a>+ </footer>+ </main><script>+ // Write the current year to the footer+ document.getElementById('year').textContent = new Date().getFullYear();+var params = new URLSearchParams(window.location.search);function buildUrl(region) {params.set('_region', region);@@ -309,9 +383,10 @@document.getElementById('btn-eu').href = buildUrl('eu');// Auto-redirect if user has previously logged in to a region- (function() {+ (function () {var REDIRECT_SECONDS = 7;- var cookie = document.cookie.split('; ').find(function(c) { return c.startsWith('ph_current_instance='); });+ var prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;+ var cookie = document.cookie.split('; ').find(function (c) { return c.startsWith('ph_current_instance='); });if (!cookie) return;var value = decodeURIComponent(cookie.substring(cookie.indexOf('=') + 1)).replace(/"/g, '');@@ -320,27 +395,32 @@var hostname = new URL(value).hostname;if (hostname === 'us.posthog.com') region = 'us';else if (hostname === 'eu.posthog.com') region = 'eu';- } catch(e) { return; }+ } catch (e) { return; }if (!region) return;var regionLabel = region === 'us' ? 'US Cloud' : 'EU Cloud';var redirectUrl = buildUrl(region);- document.getElementById('hint-default').style.display = 'none';- document.getElementById('redirect-banner').style.display = 'block';+ document.getElementById('hint-default').hidden = true;+ document.getElementById('redirect-banner').hidden = false;document.getElementById('redirect-region-name').textContent = regionLabel;document.getElementById('redirect-go-now').textContent = 'Go to ' + regionLabel + ' now';document.getElementById('redirect-go-now').href = redirectUrl;var startTime = Date.now();var fill = document.getElementById('progress-fill');+ var progressBar = document.getElementById('progress-bar');var countdown = document.getElementById('redirect-countdown');var timer = null;function tick() {var elapsed = Date.now() - startTime;var progress = Math.min(elapsed / (REDIRECT_SECONDS * 1000), 1);- fill.style.width = (progress * 100) + '%';+ var percent = Math.round(progress * 100);+ if (!prefersReducedMotion) {+ fill.style.width = percent + '%';+ progressBar.setAttribute('aria-valuenow', String(percent));+ }countdown.textContent = Math.max(0, Math.ceil(REDIRECT_SECONDS - elapsed / 1000));if (progress >= 1) {window.location.href = redirectUrl;@@ -350,12 +430,13 @@}timer = requestAnimationFrame(tick);- document.getElementById('redirect-cancel').addEventListener('click', function() {+ document.getElementById('redirect-cancel').addEventListener('click', function () {cancelAnimationFrame(timer);- document.getElementById('redirect-banner').style.display = 'none';- document.getElementById('hint-default').style.display = 'block';+ document.getElementById('redirect-banner').hidden = true;+ document.getElementById('hint-default').hidden = false;});})();</script></body>-</html>++</html>\ No newline at end of filediff --git a/services/oauth-proxy/tests/authorize.test.ts b/services/oauth-proxy/tests/authorize.test.tsindex c2eee9981f43..057b659021e0 100644--- a/services/oauth-proxy/tests/authorize.test.ts+++ b/services/oauth-proxy/tests/authorize.test.ts@@ -22,7 +22,7 @@ describe('handleAuthorize', () => {expect(response.headers.get('content-type')).toContain('text/html')const html = await response.text()- expect(html).toContain('Log in to PostHog')+ expect(html).toContain('Authenticate with PostHog')expect(html).toContain('US Cloud')expect(html).toContain('EU Cloud')})@@ -202,12 +202,15 @@ describe('handleAuthorize', () => {expect(callbackPuts).toHaveLength(0)})- it('sets security headers on region picker page', async () => {+ it('sets security and cache headers on region picker page', async () => {const request = new Request('https://oauth.posthog.com/oauth/authorize/?client_id=abc&response_type=code')const response = await handleAuthorize(request, mockKV)expect(response.headers.get('x-frame-options')).toBe('DENY')expect(response.headers.get('x-content-type-options')).toBe('nosniff')expect(response.headers.get('referrer-policy')).toBe('no-referrer')+ expect(response.headers.get('cache-control')).toBe(+ 'public, max-age=3600, s-maxage=86400, stale-while-revalidate=604800'+ )})})