Repository navigation
feat: sub-path deployment support for backend-served auth workflow UI - #3111
Conversation
When publicUrl carries a pathname (e.g. https://example.com/auth) behind a prefix-stripping reverse proxy, the embedded SSR auth pages now work: - renderUIPage rebases the fixed /public/ vite asset URLs (template tags + preload links) onto the prefix per request, keeping the prebuilt dist deployment-agnostic - the UI app derives the same prefix from the hydration payload baseURL for the vue-router history base (hydration route matching) and for inter-page hrefs / rendered redirect back-links via useBasePath() - new getURLBasePath() helper in @authup/kit extracts the normalized pathname prefix of a URL
|
Warning Review limit reached
More reviews will be available in 29 minutes and 49 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds comprehensive support for deploying the embedded SSR auth UI under a reverse-proxy path prefix. The implementation extracts base paths from URLs, rewrites server-rendered asset references, configures client-side routing with the base path, and updates navigation across five auth pages to respect the prefix without changing any exported public signatures. ChangesSub-path Deployment Support for SSR Auth UI
Sequence DiagramsequenceDiagram
participant Browser as Browser
participant Server as Server (renderUIPage)
participant Assets as /public/ Assets
participant Client as Vue App
participant Pages as Auth Pages
Browser->>Server: GET /myapp/activate (reverse proxy strips /myapp)
Server->>Server: Extract baseURL → /myapp
Server->>Server: Rebase /public/app.js → /myapp/public/app.js
Server-->>Browser: HTML with rebased asset URLs
Browser->>Assets: GET /myapp/public/app.js
Browser->>Client: Load Vue app (hydrate with baseURL)
Client->>Client: getURLBasePath(/myapp) → /myapp
Client->>Client: createWebHistory(/myapp)
Pages->>Pages: useBasePath wraps redirect → /myapp/login
Pages-->>Browser: Navigation respects base path
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
authup
@authup/client-web
@authup/server-core
@authup/access
@authup/client-web-kit
@authup/client-web-kit-theme
@authup/client-web-nuxt
@authup/client-web-theme
@authup/core-http-kit
@authup/core-kit
@authup/core-realtime-kit
@authup/errors
@authup/i18n
@authup/kit
@authup/server-adapter-kit
@authup/server-adapter-node
@authup/server-adapter-socket-io
@authup/server-adapter-web
@authup/server-kit
@authup/server-test-kit
@authup/specs
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/kit/src/url.ts`:
- Around line 24-29: getURLBasePath currently only strips trailing slashes so a
pathname like "//auth" remains "//auth" and later causes rebasePublicAssetURLs
to emit scheme-relative URLs; update getURLBasePath to first collapse duplicated
leading slashes (e.g. replace /^\/+/ with '/'), then remove trailing slashes and
return '' for the root path; ensure you modify the normalization logic in
getURLBasePath (the pathname handling code) so downstream rebasePublicAssetURLs
receives a single-leading-slash base path or empty string.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d11ea0bf-68f7-49f1-8895-22c7aa7cac76
📒 Files selected for processing (16)
.agents/architecture.mdapps/server-core/src/adapters/http/ui/base-path.tsapps/server-core/src/adapters/http/ui/index.tsapps/server-core/src/adapters/http/ui/render.tsapps/server-core/test/unit/adapters/http/ui/base-path.spec.tsapps/server-core/ui/src/app.tsapps/server-core/ui/src/base-path.tsapps/server-core/ui/src/pages/activate.vueapps/server-core/ui/src/pages/authorize.vueapps/server-core/ui/src/pages/password-forgot.vueapps/server-core/ui/src/pages/password-reset.vueapps/server-core/ui/src/pages/register.vueapps/server-core/ui/src/types.tsdocs/src/guide/deployment/configuration-server-core.mdpackages/kit/src/url.tspackages/kit/test/unit/url.spec.ts
new URL().pathname preserves leading double slashes (https://example.com//auth -> //auth), which rebasePublicAssetURLs would turn into scheme-relative asset URLs (//auth/public/...).
Summary
The embedded SSR auth pages (
/authorize,/register,/activate,/password-forgot,/password-reset) now work when authup is served under a path prefix behind a prefix-stripping reverse proxy (e.g.https://example.com/auth/* → authup /*). The prefix is derived frompublicUrl's pathname — no new config option.Previously, asset URLs were emitted root-absolute (
/public/assets/...from the fixed vitebase: '/public/'), so the browser requested them outside the proxy mapping → 404; vue-router route matching also broke on hydration, and inter-page links pointed at the site root.Changes
@authup/kit: newgetURLBasePath(url)— normalized pathname prefix of a URL (https://example.com/auth/→/auth; root/invalid →'').adapters/http/ui: newrebasePublicAssetURLs(html, basePath);renderUIPageapplies it per request using the payload'sbaseURL, rewritingsrc/href/public/...references (script/stylesheet/modulepreload/font-preload, prod + JIT). The prebuiltdist/uistays deployment-agnostic; the vite base is untouched. The attribute-syntax regex never touches the hydration payload JSON (test asserts this).ui/app: the vue-router history gets the base path (hydration route matching under the prefix); newuseBasePath()composable used by all five pages to prefix inter-page hrefs and renderedredirectback-links.redirect/requestPathquery values stay server-local — the prefix is applied only when a path is rendered as an href. Also fixed the deadpublicURLfield inHydrationPayloadto thebaseURLeverything actually sets.publicUrl), OAuth2/IdPLocationredirects (built from fullpublicUrl),AuthorizeForm'swindow.locationtargets (absolute URLs). Subdomain deployments yield an empty prefix → behavior identical to before..agents/architecture.md(Auth Workflow UI section + file map),docs/src/guide/deployment/configuration-server-core.md(publicUrlnote).Tests
packages/kit: newurl.spec.ts(suite: 20 passed)apps/server-core: newtest/unit/adapters/http/ui/base-path.spec.ts; adapters tree 31 passed; embedded UI vite build green; ESLint clean🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation