Skip to content

feat: sub-path deployment support for backend-served auth workflow UI - #3111

Merged
tada5hi merged 2 commits into
masterfrom
feat/server-ui-sub-path
Jun 11, 2026
Merged

tada5hi merged 2 commits into
masterfrom
feat/server-ui-sub-path

Conversation

@tada5hi

@tada5hi tada5hi commented Jun 11, 2026 •

Copy link
Copy Markdown
Collaborator

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 from publicUrl's pathname — no new config option.

Previously, asset URLs were emitted root-absolute (/public/assets/... from the fixed vite base: '/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: new getURLBasePath(url) — normalized pathname prefix of a URL (https://example.com/auth/ → /auth; root/invalid → '').
  • server-core, adapters/http/ui: new rebasePublicAssetURLs(html, basePath); renderUIPage applies it per request using the payload's baseURL, rewriting src/href /public/... references (script/stylesheet/modulepreload/font-preload, prod + JIT). The prebuilt dist/ui stays deployment-agnostic; the vite base is untouched. The attribute-syntax regex never touches the hydration payload JSON (test asserts this).
  • server-core, ui/ app: the vue-router history gets the base path (hydration route matching under the prefix); new useBasePath() composable used by all five pages to prefix inter-page hrefs and rendered redirect back-links. redirect/requestPath query values stay server-local — the prefix is applied only when a path is rendered as an href. Also fixed the dead publicURL field in HydrationPayload to the baseURL everything actually sets.
  • Unaffected by design (verified): API calls (kit client uses full publicUrl), OAuth2/IdP Location redirects (built from full publicUrl), AuthorizeForm's window.location targets (absolute URLs). Subdomain deployments yield an empty prefix → behavior identical to before.
  • Docs: .agents/architecture.md (Auth Workflow UI section + file map), docs/src/guide/deployment/configuration-server-core.md (publicUrl note).

Tests

  • packages/kit: new url.spec.ts (suite: 20 passed)
  • apps/server-core: new test/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

    • Support for deploying the authentication UI behind a reverse proxy that strips path prefixes from requests
    • Asset URLs and navigation links now automatically adjust when the application is deployed at sub-paths
  • Documentation

    • Updated deployment configuration guide to clarify how sub-path deployments are handled and explain the automatic path rebasing behavior

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
@coderabbitai

coderabbitai Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@tada5hi, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 933c0a10-26f1-411c-8c08-9d8f06a9f59a

📥 Commits

Reviewing files that changed from the base of the PR and between 65190fd and 791af27.

📒 Files selected for processing (2)
  • packages/kit/src/url.ts
  • packages/kit/test/unit/url.spec.ts
📝 Walkthrough

Walkthrough

This 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.

Changes

Sub-path Deployment Support for SSR Auth UI

Layer / File(s) Summary
Base path extraction utilities
packages/kit/src/url.ts, packages/kit/test/unit/url.spec.ts
getURLBasePath() extracts and normalizes the pathname prefix from a URL, returning empty string for root-level or invalid input, and is thoroughly tested across edge cases.
Server-side asset URL rewriting
apps/server-core/src/adapters/http/ui/base-path.ts, apps/server-core/test/unit/adapters/http/ui/base-path.spec.ts, apps/server-core/src/adapters/http/ui/index.ts
rebasePublicAssetURLs() rewrites HTML /public/ asset references in src and href attributes with a base path prefix, preserving embedded payloads, with corresponding unit tests and public module export.
HTML rendering integration
apps/server-core/src/adapters/http/ui/render.ts
renderUIPage() now imports getURLBasePath and rebasePublicAssetURLs to extract the base path from payload.config.baseURL and apply asset URL rebasing to the rendered HTML body.
Client-side base path configuration
apps/server-core/ui/src/types.ts, apps/server-core/ui/src/base-path.ts, apps/server-core/ui/src/app.ts
HydrationPayload.config changes from required publicURL to optional baseURL; useBasePath() composable derives and exposes the base path; Vue app router initializes with createWebHistory(basePath) and createMemoryHistory(basePath) to enable base-path-aware route matching.
Auth page link rebasing
apps/server-core/ui/src/pages/activate.vue, authorize.vue, password-forgot.vue, password-reset.vue, register.vue
Five auth pages import useBasePath() and wrap navigational links and internal paths (e.g., data.redirect, /password-reset) with the withBasePath() helper to ensure all page-to-page navigation respects the configured base path.
Documentation updates
.agents/architecture.md, docs/src/guide/deployment/configuration-server-core.md
Architecture docs explain per-request asset URL rebasing via renderUIPage, client-side routing base-path integration, and redirect handling; deployment guide clarifies that publicUrl may include a reverse-proxy path prefix and that auth page assets and links are automatically rebased.

Sequence Diagram

sequenceDiagram
  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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • authup/authup#3104: Both PRs modify the SSR auth UI rendering and hydration payload structure; this PR adds base-path asset/link rebasing support while the related PR refactors the payload supply and serialization.

Poem

🐰 A rabbit hops through proxy paths so fine,
With /public/ assets now in perfect line,
Each page remembers where it came to be,
Links rebased, routes aware, redirects free!
Sub-paths deployed with grace, no more dismay! 🌿✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main feature: adding sub-path deployment support for the backend-served auth workflow UI, which directly aligns with the PR's core objective.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/server-ui-sub-path

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-new Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

authup

npm i https://pkg.pr.new/authup@3111

@authup/client-web

npm i https://pkg.pr.new/@authup/client-web@3111

@authup/server-core

npm i https://pkg.pr.new/@authup/server-core@3111

@authup/access

npm i https://pkg.pr.new/@authup/access@3111

@authup/client-web-kit

npm i https://pkg.pr.new/@authup/client-web-kit@3111

@authup/client-web-kit-theme

npm i https://pkg.pr.new/@authup/client-web-kit-theme@3111

@authup/client-web-nuxt

npm i https://pkg.pr.new/@authup/client-web-nuxt@3111

@authup/client-web-theme

npm i https://pkg.pr.new/@authup/client-web-theme@3111

@authup/core-http-kit

npm i https://pkg.pr.new/@authup/core-http-kit@3111

@authup/core-kit

npm i https://pkg.pr.new/@authup/core-kit@3111

@authup/core-realtime-kit

npm i https://pkg.pr.new/@authup/core-realtime-kit@3111

@authup/errors

npm i https://pkg.pr.new/@authup/errors@3111

@authup/i18n

npm i https://pkg.pr.new/@authup/i18n@3111

@authup/kit

npm i https://pkg.pr.new/@authup/kit@3111

@authup/server-adapter-kit

npm i https://pkg.pr.new/@authup/server-adapter-kit@3111

@authup/server-adapter-node

npm i https://pkg.pr.new/@authup/server-adapter-node@3111

@authup/server-adapter-socket-io

npm i https://pkg.pr.new/@authup/server-adapter-socket-io@3111

@authup/server-adapter-web

npm i https://pkg.pr.new/@authup/server-adapter-web@3111

@authup/server-kit

npm i https://pkg.pr.new/@authup/server-kit@3111

@authup/server-test-kit

npm i https://pkg.pr.new/@authup/server-test-kit@3111

@authup/specs

npm i https://pkg.pr.new/@authup/specs@3111

commit: 791af27

@tada5hi
tada5hi marked this pull request as ready for review June 11, 2026 12:16
Copilot AI review requested due to automatic review settings June 11, 2026 12:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 69c776e and 65190fd.

📒 Files selected for processing (16)
  • .agents/architecture.md
  • apps/server-core/src/adapters/http/ui/base-path.ts
  • apps/server-core/src/adapters/http/ui/index.ts
  • apps/server-core/src/adapters/http/ui/render.ts
  • apps/server-core/test/unit/adapters/http/ui/base-path.spec.ts
  • apps/server-core/ui/src/app.ts
  • apps/server-core/ui/src/base-path.ts
  • apps/server-core/ui/src/pages/activate.vue
  • apps/server-core/ui/src/pages/authorize.vue
  • apps/server-core/ui/src/pages/password-forgot.vue
  • apps/server-core/ui/src/pages/password-reset.vue
  • apps/server-core/ui/src/pages/register.vue
  • apps/server-core/ui/src/types.ts
  • docs/src/guide/deployment/configuration-server-core.md
  • packages/kit/src/url.ts
  • packages/kit/test/unit/url.spec.ts

Comment thread packages/kit/src/url.ts Resolved
new URL().pathname preserves leading double slashes
(https://example.com//auth -> //auth), which rebasePublicAssetURLs
would turn into scheme-relative asset URLs (//auth/public/...).
@tada5hi
tada5hi merged commit 7fa7a68 into master Jun 11, 2026
14 checks passed
@tada5hi
tada5hi deleted the feat/server-ui-sub-path branch June 11, 2026 13:13
@github-actions github-actions Bot mentioned this pull request Jun 11, 2026
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.

2 participants