web: fix 500 on /banner by using absolute redirect destination#13
Conversation
The /banner redirect 500s under the OpenNext/Cloudflare runtime. Its URL parser treats the empty path segment of a root-relative '/?utm_...' destination as the entire string and hands '/?...' to path-to-regexp, which throws "Unexpected MODIFIER" on the bare '?'. Pointing the redirect at the absolute homepage URL routes through the external-URL parsing branch, which splits the path and query correctly. Verified against an OpenNext preview build: /banner now returns 307 to the UTM-tagged homepage instead of 500. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KR8qT4wbqAZMLjqU2D4JGG
|
Warning Review limit reached
More reviews will be available in 49 minutes and 8 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ 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 |
There was a problem hiding this comment.
Code Review
This pull request updates the /banner redirect destination in web/next.config.mjs to use an absolute URL instead of a relative path, resolving a 500 error in the OpenNext/Cloudflare runtime. The reviewer suggested dynamically determining the base URL using environment variables to prevent breaking redirects during local development and in preview environments.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| destination: | ||
| '/?utm_source=ai-engineer-worldfair&utm_medium=banner&utm_campaign=ai-engineer-worldfair-2026', | ||
| 'https://agentrelay.com/?utm_source=ai-engineer-worldfair&utm_medium=banner&utm_campaign=ai-engineer-worldfair-2026', |
There was a problem hiding this comment.
Hardcoding the production domain https://agentrelay.com breaks the redirect during local development (where it will redirect to production instead of localhost) and in preview/staging environments.
To make this robust across all environments, consider dynamically determining the base URL using environment variables (like NEXT_PUBLIC_SITE_URL) and falling back to http://localhost:3000 in development.
| destination: | |
| '/?utm_source=ai-engineer-worldfair&utm_medium=banner&utm_campaign=ai-engineer-worldfair-2026', | |
| 'https://agentrelay.com/?utm_source=ai-engineer-worldfair&utm_medium=banner&utm_campaign=ai-engineer-worldfair-2026', | |
| destination: | |
| `${process.env.NEXT_PUBLIC_SITE_URL || (process.env.NODE_ENV === 'development' ? 'http://localhost:3000' : 'https://agentrelay.com')}/?utm_source=ai-engineer-worldfair&utm_medium=banner&utm_campaign=ai-engineer-worldfair-2026`, |
|
Preview deployed!
This is a Cloudflare Workers preview version of this PR's build. |
Problem
https://agentrelay.com/bannerreturns a 500 Internal Server Error./banneris a redirect defined inweb/next.config.mjspointing at the homepage with UTM tags:destination: '/?utm_source=...&utm_medium=banner&utm_campaign=...'The site is served via OpenNext on Cloudflare Workers. OpenNext's runtime router parses each redirect destination with
getUrlParts(), whose regex treats the empty path segment of a root-relative/?...URL as falsy and falls back to using the entire string (including the?) as the pathname. It then eagerly hands that to path-to-regexp'scompile(), and path-to-regexp v8 throwsUnexpected MODIFIERon the bare?→ 500.The other redirects (
/quickstart,/relayfile, …) are unaffected because they have a non-empty path segment and no query string./bannerwas the only redirect targeting the root path with a query.Fix
Point the redirect at the absolute homepage URL:
destination: 'https://agentrelay.com/?utm_source=...&utm_medium=banner&utm_campaign=...'This routes through OpenNext's external-URL parsing branch, which separates path (
/) and query correctly, socompile()never sees the stray?. The UTM tags and the temporary (307) redirect semantics are preserved. A comment documents why the absolute form is required.Verification
next build+opennextjs-cloudflare build) and confirmed/bannerreturns307 → https://agentrelay.com/?utm_source=....vitest run).🤖 Generated with Claude Code
https://claude.ai/code/session_01KR8qT4wbqAZMLjqU2D4JGG
Generated by Claude Code
Summary by cubic
Fixes a 500 on /banner by switching the redirect to an absolute homepage URL. The route now returns a 307 to the UTM-tagged homepage instead of failing.
/bannerto avoid apath-to-regexperror inOpenNextwhen parsing root-relative/?...destinations./bannernow redirects as expected.Written for commit 2e1eeeb. Summary will update on new commits.