Skip to content

fix(cors): add admin.packratai.com + *.workers.dev to root cors allow…#2411

Merged
andrew-bierman merged 1 commit into
mainfrom
fix/cors-preflight-root-allowlist
May 12, 2026
Merged

fix(cors): add admin.packratai.com + *.workers.dev to root cors allow…#2411
andrew-bierman merged 1 commit into
mainfrom
fix/cors-preflight-root-allowlist

Conversation

@andrew-bierman
Copy link
Copy Markdown
Collaborator

…list

Root cors runs first and short-circuits OPTIONS preflights before the admin-scoped cors plugin can set Access-Control-Allow-Origin. Admin origin was only in the admin-scoped plugin, so preflights from admin.packratai.com got no origin header. Non-preflight requests worked because the full middleware chain ran and the admin cors added the header to the response.

Fix: add admin.packratai.com and *.workers.dev to root cors allowlist so OPTIONS preflights get the origin header reflected back correctly.

Description

Closes #

Type of change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor / code improvement
  • 📝 Documentation update
  • 🔧 CI / configuration change
  • ⬆️ Dependency update
  • 🗄️ Database migration

Area(s) affected

  • Mobile app (apps/expo)
  • API / Backend (packages/api)
  • Landing page (apps/landing)
  • Guides site (apps/guides)
  • CI / CD (.github/)

Testing

  • Added / updated unit tests
  • Manually tested on iOS
  • Manually tested on Android
  • Manually tested on Web
  • API endpoints verified (e.g. curl or Postman)

Screenshots / recordings

Pre-merge checklist

  • bun format && bun lint passes with no errors
  • bun check-types passes with no errors
  • No new secrets or credentials are committed
  • Database migration included (if schema changed)
  • Feature flag added (if this is a new feature)
  • PR title follows conventional commits (feat:, fix:, chore:, etc.)

…list

Root cors runs first and short-circuits OPTIONS preflights before the
admin-scoped cors plugin can set Access-Control-Allow-Origin. Admin origin
was only in the admin-scoped plugin, so preflights from admin.packratai.com
got no origin header. Non-preflight requests worked because the full
middleware chain ran and the admin cors added the header to the response.

Fix: add admin.packratai.com and *.workers.dev to root cors allowlist so
OPTIONS preflights get the origin header reflected back correctly.
@andrew-bierman andrew-bierman marked this pull request as ready for review May 12, 2026 17:58
Copilot AI review requested due to automatic review settings May 12, 2026 17:58
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

Warning

Rate limit exceeded

@andrew-bierman has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 14 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2d96a687-521b-4490-87a4-32f007255ec0

📥 Commits

Reviewing files that changed from the base of the PR and between 59e93ae and fca7d17.

📒 Files selected for processing (1)
  • packages/api/src/index.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cors-preflight-root-allowlist

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.

@andrew-bierman andrew-bierman merged commit e1ac84f into main May 12, 2026
9 checks passed
@andrew-bierman andrew-bierman deleted the fix/cors-preflight-root-allowlist branch May 12, 2026 17:58
@github-actions github-actions Bot added the api label May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Coverage Report for API Unit Tests Coverage (./packages/api)

Status Category Percentage Covered / Total
🔵 Lines 76.17% 502 / 659
🔵 Statements 76.17% (🎯 65%) 502 / 659
🔵 Functions 95% 38 / 40
🔵 Branches 88.67% 227 / 256
File CoverageNo changed files found.
Generated in workflow #1160 for commit fca7d17 by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown
Contributor

Coverage Report for Expo Unit Tests Coverage (./apps/expo)

Status Category Percentage Covered / Total
🔵 Lines 82.61% 480 / 581
🔵 Statements 82.61% (🎯 75%) 480 / 581
🔵 Functions 92.59% 50 / 54
🔵 Branches 90.9% 170 / 187
File CoverageNo changed files found.
Generated in workflow #1160 for commit fca7d17 by the Vitest Coverage Report Action

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the API Worker’s root CORS allowlist so OPTIONS preflight requests can be correctly short-circuited with an Access-Control-Allow-Origin response for the admin SPA and Workers dev origins (matching the existing admin-scoped CORS behavior).

Changes:

  • Added packratai.com subdomain support to the root CORS origin allowlist.
  • Added workers.dev support to the root CORS origin allowlist to cover preflight handling earlier in the middleware chain.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/api/src/index.ts
/^https:\/\/(www\.)?packrat\.world$/,
/^https:\/\/[\w-]+\.packrat\.world$/,
/^https:\/\/[\w-]+\.packratai\.com$/,
/^https?:\/\/[\w-]+\.workers\.dev$/,
Comment thread packages/api/src/index.ts
Comment on lines 34 to +37
/^https:\/\/(www\.)?packrat\.world$/,
/^https:\/\/[\w-]+\.packrat\.world$/,
/^https:\/\/[\w-]+\.packratai\.com$/,
/^https?:\/\/[\w-]+\.workers\.dev$/,
Comment thread packages/api/src/index.ts
Comment on lines 32 to +36
// Allow the API base URL and any subdomain of packrat.world
const allowed = [
/^https:\/\/(www\.)?packrat\.world$/,
/^https:\/\/[\w-]+\.packrat\.world$/,
/^https:\/\/[\w-]+\.packratai\.com$/,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants