Skip to content

fix(app-core): preserve middleware RPC exposed headers - #1471

Merged
trueadm merged 4 commits into
octanejs:mainfrom
Rober1208:codex/preserve-rpc-exposed-headers
Oct 1, 2026
Merged

trueadm merged 4 commits into
octanejs:mainfrom
Rober1208:codex/preserve-rpc-exposed-headers

Conversation

@Rober1208

@Rober1208 Rober1208 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Trusted cross-origin RPC responses overwrite middleware's Access-Control-Expose-Headers, so browsers cannot read explicitly exposed headers such as Retry-After and X-Request-Id. Append Octane-RPC-Outcome to the existing list instead, preserving middleware visibility and the rejected outcome.

Add handler regression coverage and seven real Chromium cases covering explicit/mixed-case lists, wildcard, empty/missing lists, same-origin/native Fetch controls, and blocked untrusted/credentialed preflights. Route the browser project through the existing heavy-browser partition.

Fixes #1361.

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm test
  • targeted tests: NODE_ENV=development and NODE_ENV=production, each running node node_modules/vitest/vitest.mjs run --project app-core --project app-core-browser packages/app-core/tests/rpc.test.ts packages/app-core/tests/browser/rpc.test.ts — 62 passed in each mode. Restoring only the RPC implementation from base 73138de044b0b08e8873306970c1ec64da0896c3 makes six regressions fail in each mode (56 passed).

Changed-file Prettier, app-core typecheck, changeset validation/release plan, and git diff --check pass. Partition checks collect 55 RPC handler cases in the ordinary project and seven unique browser cases in the heavy project.

The full app-core project run in each mode has two failing codegen tests, a Windows symlink EPERM setup failure, and its teardown error; all reproduce on the completely unchanged base. Candidate: 220 passed / 6 skipped; base: 209 passed / 6 skipped. pnpm run sync also fails at the same animejs bindings validation on both revisions without tracked generated changes; later sync stages were not reached. Whole-repository format/type/test commands were not run.

Local validation used Windows, Node 24.16.0 and headless Chromium, with a workspace-only hidden-subprocess preload applied consistently to base and candidate runs. That launch instrumentation is not part of this diff.

CI follow-up

Synchronized with upstream main 874ca5f139c6ed6f29b4970a567bc7e22b0b3ca4 and regenerated the user-app corpus after this PR's Vitest configuration change. Relative to that merged base, only 21 grader.graderDigest values change; training data and upstream environment metadata remain unchanged. The two corpus assertions that failed in CI now pass locally (the other four cases were excluded by the focused selection). The RPC handler and headless Chromium suites pass again in development and production (62 tests in each mode).

pnpm sync with pnpm 11.15.1, including nested pnpm commands, stops at the same animejs binding-metadata validation error as an independently checked pristine copy of that upstream commit; later synchronization stages were not reached. Existing dependency views were reused, so the newly merged TanStack dependency patch and full repository installation were not validated locally. Full substantive CI must run on this pushed head.

Risk / follow-ups

This preserves middleware's exposure policy, including wildcard behavior; it does not add credentialed CORS support or change origin authorization. Existing case-insensitive outcome names may appear twice in the exposure list, which Fetch handles as a header-name list. No performance improvement is claimed.

Provenance

  • An agent produced this diff (agent-authored)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
The change affects cross-origin RPC CORS header merging, including wildcard expose lists; origin authorization behavior is unchanged but more middleware headers may become visible to trusted browsers.

Overview
Trusted cross-origin RPC responses were replacing middleware Access-Control-Expose-Headers with only Octane-RPC-Outcome, so browsers could not read headers like Retry-After or X-Request-Id even when middleware explicitly exposed them.

withRpcCors now appends Octane-RPC-Outcome to any existing expose list instead of overwriting it, while still adding CORS allow-origin and Vary: Origin.

Coverage adds handler regressions (authorization/rate-limit cases, wildcard/empty/missing lists) and a new Playwright/Chromium suite that checks real cross-origin fetch header visibility against a native Fetch control. Vitest splits app-core node tests from a app-core-browser project on the heavy-browser partition. Eval manifest.jsonl grader digests were regenerated after that config change.

Reviewed by Cursor Bugbot for commit 7beab06. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Sep 30, 2026
@trueadm
trueadm marked this pull request as ready for review September 30, 2026 20:41
Copilot AI balanced review requested due to automatic review settings September 30, 2026 22:31

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@trueadm
trueadm merged commit 6615a19 into octanejs:main Oct 1, 2026
29 checks passed
trueadm added a commit that referenced this pull request Oct 1, 2026
Brings in #1500, #1471, and #1502. #1500 changes vitest.config.js, which every
user-app grader digest covers, so manifest.jsonl is regenerated rather than
hand-merged. The Strong repair ledger, prompts, and alternatives are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trusted cross-origin RPC hides middleware-exposed Retry-After and request ID headers

3 participants