fix(server): match browser extension CORS origins exactly - #850
fix(server): match browser extension CORS origins exactly#850eachann1024 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughCORS allowlist matching now supports configured browser extension origins through canonical scheme-and-authority comparison. Tests cover Chrome extension access and rejection cases. Type and reference documentation describe exact-origin behavior and clarify that ChangesBrowser Extension CORS Origins
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs-site/src/content/docs/reference/configuration.md`:
- Line 73: Update the corsAllowOrigins documentation rows in the Japanese,
Korean, and Russian localized pages to match the English description: state that
authority-based browser extension origins such as
chrome-extension://<extension-id> are supported and that * is not a wildcard,
while preserving the existing configuration details.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 4302c78e-3c2b-4608-bf78-fba4afa2469f
📒 Files selected for processing (6)
docs-site/src/content/docs/reference/configuration.mddocs-site/src/content/docs/zh-cn/reference/configuration.mdsrc/server/auth-cors.tssrc/types.tstests/server-auth.test.tstests/server-loopback-host-gate.test.ts
| | `images?` | `OcxImagesConfig` | automatic OpenAI selection | Standalone Images relay options for Codex's built-in `image_gen` tool (see below). | | ||
| | `tokenGuardian?` | `OcxTokenGuardianConfig` | off | Optional proactive OAuth refresh and Codex-account warmup policy; fields are listed below. | | ||
| | `corsAllowOrigins?` | `string[]` | `[]` | Additional exact origins allowed by CORS. Loopback origins are always allowed. | | ||
| | `corsAllowOrigins?` | `string[]` | `[]` | Additional exact origins allowed by CORS. Loopback origins are always allowed. Authority-based browser extension origins such as `chrome-extension://<extension-id>` are supported; `*` is not a wildcard. | |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
fd -i '^configuration\.md$' docs-site/src/content/docs | sort
rg -n -C 2 'corsAllowOrigins|chrome-extension|not a wildcard|不是通配符' \
docs-site/src/content/docsRepository: lidge-jun/opencodex
Length of output: 6108
Sync localized CORS documentation
Update the corsAllowOrigins rows in the Japanese (line 66), Korean (line 67), and Russian (line 71) pages. State that chrome-extension://<extension-id> origins are supported and * is not a wildcard.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs-site/src/content/docs/reference/configuration.md` at line 73, Update the
corsAllowOrigins documentation rows in the Japanese, Korean, and Russian
localized pages to match the English description: state that authority-based
browser extension origins such as chrome-extension://<extension-id> are
supported and that * is not a wildcard, while preserving the existing
configuration details.
Source: Path instructions
What changed
nullserialization*rejected/v1/modelsdata-plane requestsWhy
URL.originserializeschrome-extension://...URLs asnull. Comparing that value made every browser extension look identical, while rejecting a wildcard configuration still left users without a safe way to allow one extension to call the local data plane.Change graph
flowchart LR Request["Browser extension request"] --> Parse["Parse request origin"] Allowlist["corsAllowOrigins"] --> Match["Exact origin matcher"] Parse --> Standard["Standard HTTP(S) origin"] Parse --> Opaque["Opaque authority origin"] Standard --> Match Opaque --> Authority["Compare scheme + authority"] Authority --> Match Match --> Decision{"Allowlisted?"} Decision -->|Yes| DataPlane["OpenCodeX data plane"] Decision -->|No| Rejected["403 origin_rejected"]Checks
bun test tests/server-loopback-host-gate.test.ts tests/server-auth.test.ts tests/management-origin-tls.test.ts(76 passed)bun run typecheckbun run lint:guibun run privacy:scancd docs-site && bun run buildOPTIONS /v1/models= 204,GET /v1/models= 200, different extension = 403origin_rejectedupstream/devbecause local Fake-IP DNS resolves.test/.invalidfixtures into198.18.0.0/15and the destination policy rejects them (tests/provider-outbound.test.ts,tests/management-provider-validation.test.ts)Checklist
Summary by CodeRabbit
New Features
chrome-extension://<extension-id>.Documentation
*is not a wildcard.