-
Notifications
You must be signed in to change notification settings - Fork 1
fix(auth): check AGENTUITY_CLOUD_BASE_URL first for base URL resolution #633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When custom domains are configured, the platform sets AGENTUITY_CLOUD_BASE_URL with the correct custom domain URL. This change updates the auth package to check this env var first, ensuring auth redirects use the correct HTTPS custom domain URL instead of the default deployment URL. Priority order is now: 1. Explicit baseURL option 2. AGENTUITY_CLOUD_BASE_URL (platform-injected for cloud deployments) 3. AGENTUITY_BASE_URL (legacy fallback) 4. BETTER_AUTH_URL (BetterAuth standard) Co-Authored-By: grodrigues@agentuity.com <huijirohankei@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
📝 WalkthroughWalkthroughAuth base URL resolution now returns the first non-empty candidate from [explicit Changes
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✏️ Tip: You can disable this entire section by setting Comment |
📦 Canary Packages Publishedversion: PackagesInstallAdd to your {
"dependencies": {
"@agentuity/react": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-react-0.1.16-d0bab70.tgz",
"@agentuity/evals": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-evals-0.1.16-d0bab70.tgz",
"@agentuity/schema": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-schema-0.1.16-d0bab70.tgz",
"@agentuity/auth": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-auth-0.1.16-d0bab70.tgz",
"@agentuity/server": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-server-0.1.16-d0bab70.tgz",
"@agentuity/runtime": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-runtime-0.1.16-d0bab70.tgz",
"@agentuity/opencode": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-opencode-0.1.16-d0bab70.tgz",
"@agentuity/frontend": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-frontend-0.1.16-d0bab70.tgz",
"@agentuity/workbench": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-workbench-0.1.16-d0bab70.tgz",
"@agentuity/core": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-core-0.1.16-d0bab70.tgz",
"@agentuity/cli": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-cli-0.1.16-d0bab70.tgz"
}
}Or install directly: bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-react-0.1.16-d0bab70.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-evals-0.1.16-d0bab70.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-schema-0.1.16-d0bab70.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-auth-0.1.16-d0bab70.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-server-0.1.16-d0bab70.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-runtime-0.1.16-d0bab70.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-opencode-0.1.16-d0bab70.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-frontend-0.1.16-d0bab70.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-workbench-0.1.16-d0bab70.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-core-0.1.16-d0bab70.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.16-d0bab70/agentuity-cli-0.1.16-d0bab70.tgzCLI Executables
Run Canary CLIagentuity canary 0.1.16-d0bab70 [command] [...args] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/auth/src/agentuity/config.ts`:
- Around line 160-172: resolveBaseURL currently uses nullish coalescing which
treats empty strings as valid and prevents falling back; update resolveBaseURL
to treat empty/whitespace env vars as missing by trimming each candidate
(explicitBaseURL, process.env.AGENTUITY_CLOUD_BASE_URL,
process.env.AGENTUITY_BASE_URL, process.env.BETTER_AUTH_URL) and returning the
first non-empty trimmed value. Locate the resolveBaseURL function and replace
the simple ?? chain with logic that checks/trims each source (explicitBaseURL,
AGENTUITY_CLOUD_BASE_URL, AGENTUITY_BASE_URL, BETTER_AUTH_URL) and skips any
that are undefined/null or only whitespace before returning the selected base
URL.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/auth/src/agentuity/config.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use Prettier formatter with tabs (width 3), single quotes, and semicolons for TypeScript files
Use TypeScript strict mode with ESNext target and bundler moduleResolution
UseStructuredErrorfrom@agentuity/corefor error handling
Files:
packages/auth/src/agentuity/config.ts
packages/auth/**/*.{ts,tsx}
📄 CodeRabbit inference engine (packages/auth/AGENTS.md)
packages/auth/**/*.{ts,tsx}: All public APIs should use the 'AgentuityAuth' prefix instead of 'BetterAuth'
All React code should be imported from '@agentuity/auth/react', including AuthProvider, createAuthClient, and useAuth
Files:
packages/auth/src/agentuity/config.ts
packages/auth/**/config.ts
📄 CodeRabbit inference engine (packages/auth/AGENTS.md)
packages/auth/**/config.ts: Prefer environment variable 'AGENTUITY_AUTH_SECRET' over 'BETTER_AUTH_SECRET'
Set default basePath to '/api/auth' for authentication routes
Enable emailAndPassword authentication by default
Use the 'organization' plugin by default for multi-tenancy support
Use the 'jwt' plugin by default for token generation
Use the 'bearer' plugin by default for bearer token authentication
Use the 'apiKey' plugin by default for API key management
Files:
packages/auth/src/agentuity/config.ts
🧠 Learnings (1)
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.
Applied to files:
packages/auth/src/agentuity/config.ts
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Update resolveBaseURL to treat empty or whitespace-only env vars as missing by trimming each candidate and returning the first non-empty trimmed value. This prevents empty strings from blocking fallback to subsequent env vars. Co-Authored-By: grodrigues@agentuity.com <huijirohankei@gmail.com>
604e098 to
d0bab70
Compare
Summary
Fixes auth redirect URL issue for custom domains. When a custom domain like
https://ops.agentuity.team/is configured, auth redirects were incorrectly usinghttp://p{hash}-{region}.agentuity.runinstead of the custom domain.The platform (catalyst) already sets
AGENTUITY_CLOUD_BASE_URLwith the correct custom domain URL, but the auth package was only checkingAGENTUITY_BASE_URL. This change updates the priority order to checkAGENTUITY_CLOUD_BASE_URLfirst:baseURLoptionAGENTUITY_CLOUD_BASE_URL(platform-injected for cloud deployments)AGENTUITY_BASE_URL(legacy fallback)BETTER_AUTH_URL(BetterAuth standard)Review & Testing Checklist for Human
AGENTUITY_CLOUD_BASE_URLcorrectly for deployments with custom domains (checkserver/apis/machine/machine_2025_03_17.goaround line 468)Notes
Requested by @Huijiro
Link to Devin run: https://app.devin.ai/sessions/bc4a879afb154bb5afd136ed266fee5b
Summary by CodeRabbit
Bug Fixes
Chores
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.