Skip to content

test(api): lock in production CORS origins, use reserved example domains - #3523

Merged
tofikwest merged 2 commits into
mainfrom
tofik/cors-production-origin-tests
Jul 28, 2026
Merged

test(api): lock in production CORS origins, use reserved example domains#3523
tofikwest merged 2 commits into
mainfrom
tofik/cors-production-origin-tests

Conversation

@tofikwest

@tofikwest tofikwest commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Two test-only changes. No production code.

1. Lock in that production origins still pass CORS

#3064 replaced app.enableCors() with a custom middleware so the questionnaire extension could be allowed on specific routes. Nothing asserted the existing apps still pass.

Covers the four origin classes that actually reach production:

  • app.trycomp.ai
  • portal.trycomp.ai
  • an arbitrary *.trycomp.ai subdomain
  • a customer custom domain (resolved through the Redis/DB lookup, not a trycomp.ai host)

Plus two guards: an untrusted origin is still rejected, and resolution does not depend on AUTH_TRUSTED_ORIGINS — the API is not given that variable in production, so it falls back to the built-in default list.

2. Stop publishing real identifiers in a public repo

The existing auth specs contained:

  • a developer's real local unpacked-extension id, hardcoded in three files
  • evil.com and acmecorp.com — both real, registrable domains

Replaced with a synthetic extension id and RFC 2606 reserved names (untrusted.example, trust.example.com), and dropped the attack framing. Test behaviour is unchanged.

Verification

cd apps/api && bunx jest src/auth
148 passed

The one failure in that suite (domainVerified) is pre-existing on main and unrelated.

The CORS layer was replaced in #3064 to support the questionnaire
extension. These assert the four origin classes that actually reach
production — the app, the portal, an arbitrary trycomp.ai subdomain, and a
customer custom domain — still receive the right headers, that an
untrusted origin is still rejected, and that resolution does not depend on
AUTH_TRUSTED_ORIGINS, which the API is not given in production.

Tests only; no production code changes.
@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
comp-framework-editor Ready Ready Preview, Comment Jul 28, 2026 7:22pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
app Skipped Skipped Jul 28, 2026 7:22pm
portal Skipped Skipped Jul 28, 2026 7:22pm

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

The specs hardcoded a developer's real local unpacked-extension id and
used evil.com / acmecorp.com, both of which are real registrable domains,
in a public repository.

Replace them with a synthetic extension id and RFC 2606 reserved names
(untrusted.example, trust.example.com), and drop the attack framing.
Behaviour of the tests is unchanged.
@vercel
vercel Bot temporarily deployed to Preview – app July 28, 2026 19:18 Inactive
@vercel
vercel Bot temporarily deployed to Preview – portal July 28, 2026 19:18 Inactive
@tofikwest tofikwest changed the title test(api): lock in that production origins still pass CORS test(api): lock in production CORS origins, use reserved example domains Jul 28, 2026
@tofikwest
tofikwest merged commit 67b0c90 into main Jul 28, 2026
10 of 11 checks passed
@tofikwest
tofikwest deleted the tofik/cors-production-origin-tests branch July 28, 2026 19:21
@claudfuen

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.111.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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