Skip to content

feat: add native-first inbound and outbound proxy rules#479

Open
riderx wants to merge 1 commit intodevelopmentfrom
codex/native-proxy-rules
Open

feat: add native-first inbound and outbound proxy rules#479
riderx wants to merge 1 commit intodevelopmentfrom
codex/native-proxy-rules

Conversation

@riderx
Copy link
Member

@riderx riderx commented Mar 17, 2026

Summary

  • add native-first outbound and inbound proxy rule support on Android and iOS
  • keep JS proxy handling as an explicit delegate path only for matched rules
  • extend proxy events so JS can override requests outbound or responses inbound

Verification

  • bunx tsc --noEmit
  • bunx eslint .
  • ./gradlew build test
  • xcodebuild -scheme CapgoInappbrowser -destination generic/platform=iOS
  • bunx docgen --api InAppBrowserPlugin --output-readme README.md --output-json dist/docs.json
  • bunx rollup -c rollup.config.mjs
  • bun run build:proxy-bridge

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 18529666-4d14-4262-8cfe-157767b2b461

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/native-proxy-rules
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 3f59d284f5

ℹ️ 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".

var proxyHandler: ProxySchemeHandler? = nil
if proxyRequests {
proxyHandler = ProxySchemeHandler(plugin: self, webviewId: webViewId)
if proxyRequests || !outboundProxyRules.isEmpty || !inboundProxyRules.isEmpty {

Choose a reason for hiding this comment

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

P1 Badge Enable iOS proxy path when only native rules are set

This branch now creates a ProxySchemeHandler when rule arrays are provided, but the webview still receives proxyRequests: false in rules-only mode, and WKWebViewController.initWebview registers the http/https scheme handler only when proxyRequests is true (WKWebViewController.swift:679). In practice, outboundProxyRules/inboundProxyRules configured without proxyRequests never run on iOS, so the new native-first rule feature is silently disabled.

Useful? React with 👍 / 👎.

Comment on lines +2651 to +2653
NativeResponseData nativeResponse;
try {
nativeResponse = performNativeRequest(requestContext);

Choose a reason for hiding this comment

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

P1 Badge Preserve direct request bodies on Android pass-through

After outbound handling, the code unconditionally replays requests via performNativeRequest instead of letting unmatched/null-decision requests continue through WebView. For non-/_capgo_proxy_ requests, request bodies are unavailable and initialized as empty, so POST/PUT form navigations are resent without payload. That changes legacy proxyRequests pass-through semantics and can break server-side form/auth flows whenever proxying is enabled.

Useful? React with 👍 / 👎.

Comment on lines +320 to +323
self.pendingTasks.removeValue(forKey: requestId)
self.taskLock.unlock()

task.didFailWithError(NSError(
pendingTask.schemeTask.didFailWithError(NSError(

Choose a reason for hiding this comment

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

P2 Badge Cancel proxy timeout once JS decision is received

The timeout always removes a still-pending task after 10 seconds and fails it, but tasks remain in pendingTasks while executeNativePipeline is running after a valid outbound JS response. On slow upstream responses, delegated requests can be aborted at 10s even though JS answered in time, causing spurious NSURLErrorTimedOut failures.

Useful? React with 👍 / 👎.

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