Skip to content

fix: skip auth middleware for internal /__-prefixed routes - #28

Merged
Brooooooklyn merged 1 commit into
mainfrom
fix/skip-auth-internal-routes
Mar 25, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
fix/skip-auth-internal-routes

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Mar 25, 2026 •

Copy link
Copy Markdown
Member

When auth is enabled, the global auth middleware runs on all Hono routes including internal ones like /__scheduled, /__queue, and /__void/*. When the CronScheduler DO dispatches cron jobs via worker.fetch(), the request hostname is "internal" (not localhost), causing resolveSecret() to throw if BETTER_AUTH_SECRET is not set.

Add an early return in runVoidAuthMiddleware for paths starting with /__ to bypass auth on internal platform routes.


Note

Medium Risk
Changes global auth middleware behavior to skip authentication on any '/__'-prefixed path; if any externally reachable route shares this prefix, it could unintentionally bypass auth. Otherwise the change is small and scoped to internal platform endpoints.

Overview
Skips running Better Auth for internal '/__'-prefixed routes (e.g. cron/queue/migration/binding proxy) by adding an early return in runVoidAuthMiddleware.

When skipping, it explicitly sets c.set('user', null) and c.set('session', null) so downstream middleware sees consistent sentinel values instead of undefined.

Written by Cursor Bugbot for commit a242d43. This will update automatically on new commits. Configure here.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 04edeab9e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/void/src/runtime/better-auth-shared.ts
When auth is enabled, the global auth middleware runs on all Hono routes
including internal ones like /__scheduled, /__queue, and /__void/*.
When the CronScheduler DO dispatches cron jobs via worker.fetch(), the
request hostname is "internal" (not localhost), causing resolveSecret()
to throw if BETTER_AUTH_SECRET is not set.

Add an early return in runVoidAuthMiddleware for paths starting with
/__ to bypass auth on internal platform routes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Brooooooklyn
Brooooooklyn force-pushed the fix/skip-auth-internal-routes branch from 04edeab to a242d43 Compare March 25, 2026 03:30

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Brooooooklyn
Brooooooklyn merged commit d109517 into main Mar 25, 2026
8 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/skip-auth-internal-routes branch March 25, 2026 03:37
cpojer pushed a commit that referenced this pull request Sep 11, 2026
* feat: add platform worker rollback admin page

Add /admin/platform page showing all 5 platform CF Workers (proxy, tail,
api, dashboard, dispatch) with their current versions and one-click
rollback via the CF Workers Versions/Deployments API.

- Overview page with environment toggle (production/staging)
- Per-worker detail page with version history and rollback buttons
- Dependency graph derived from dependsOn (single source of truth)
- Graceful degradation via Promise.allSettled when CF API is unreachable
- Warning banner for void-api (self-rollback + migration notes)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add platform rollback audit log, unified rollback, orchestration

- Add platform_events table for audit trail (tracks who rolled back what)
- Add "Rollback All Workers" with sequential orchestration and stop-on-failure
- Add batch rollback results page and GET /events/:batchId for history
- Log events for both single and batch rollbacks (success/failure)
- Show recent activity on platform overview page
- Update progress.md with rollback milestones

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: collapse batch events, add pagination, fix rollback target

- Collapse batch rollback events into single rows in activity log
- Add paginated activity history (15 entries per page)
- Fix rollback target to find first deployment with a different version
  (prevents rollback-all from undoing a prior single rollback)
- Add version diff confirm popup before rollback-all

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor: dedup STATUS_COLORS, simplify rollback handler, fix O(n2) collapse

- Extract STATUS_COLORS to shared format.ts
- Collapse duplicate createPlatformEvent calls in single rollback
- Fix PlatformEnv | string to just PlatformEnv
- Remove dead logic in allHaveRollbackTarget
- Fix O(n2) collapseEvents with pre-built Map
- Bulk update skipped batch events in one query

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: sort batch rollback results by execution order, not timestamp

Events inserted via Promise.all get non-deterministic timestamps.
Sort by reverse deployOrder in the view to match actual rollback
execution order.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: scope platform rollback to current worker environment

Production and staging use different databases (Hyperdrive), so
cross-environment rollback wrote audit logs to the wrong DB.
Environment is now determined by PLATFORM_ENV worker var instead
of a query parameter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant