Skip to content

fix(@expo/apple-utils): patch getNextUrl() to fix pagination cookie domain mismatch (#3392)#3533

Closed
adityapsbisht wants to merge 2 commits intoexpo:mainfrom
adityapsbisht:fix/apple-utils-pagination-cookie-domain-mismatch
Closed

fix(@expo/apple-utils): patch getNextUrl() to fix pagination cookie domain mismatch (#3392)#3533
adityapsbisht wants to merge 2 commits intoexpo:mainfrom
adityapsbisht:fix/apple-utils-pagination-cookie-domain-mismatch

Conversation

@adityapsbisht
Copy link

Summary

Fixes the Cookie not in this host's domain. Cookie:developer-mdn.apple.com Request:developer.apple.com error that causes iOS builds to fail at the capability/provisioning profile sync step.

Closes #3392

Root Cause

Apple's paginated API responses include links.next with absolute URLs like https://developer.apple.com/services-account/v1/....

In ConnectResponse.fetchNextPageAsync() inside @expo/apple-utils, these absolute URLs are passed directly to axios. When an axios request URL is already absolute, axios ignores the configured baseURL (https://developer-mdn.apple.com). The request hits developer.apple.com instead, and tough-cookie correctly rejects the developer-mdn.apple.com session cookies for that domain → build fails.

TypeScript Fix Needed in @expo/apple-utils

// packages/apple-utils/src/... (ConnectResponse class)

// Before
getNextUrl(): string | null {
  return this.data?.links?.next ?? null;
}

// After — strip domain from absolute pagination URLs so axios uses baseURL
getNextUrl(): string | null {
  const next = this.data?.links?.next ?? null;
  if (!next) return null;
  try {
    const parsed = new URL(next);
    return parsed.pathname + parsed.search;
  } catch {
    return next;
  }
}

This PR

Since @expo/apple-utils source is not in this repo, this PR adds a postinstall script (scripts/patch-apple-utils-pagination.js) that applies the same fix to the compiled build/index.js after install.

The script:

  • Is a no-op if already patched (idempotent)
  • Warns gracefully if the pattern is not found (different version)
  • Self-documents exactly what TypeScript change is needed upstream

Remove this script once @expo/apple-utils publishes a version containing the fix.

Verification

Fix confirmed working by community members in #3392 (reported Feb 2026, confirmed Mar 17 2026).

Error before fix:

✖ Failed to sync capability identifiers com.example.app
Cookie not in this host's domain. Cookie:developer-mdn.apple.com Request:developer.apple.com
    Error: build command failed.

After fix: capability sync and provisioning profile steps complete successfully.

Made with Cursor

…on domain

Applies a postinstall fix for the cookie domain mismatch in @expo/apple-utils
v2.1.13 that causes `Cookie not in this host's domain` errors during iOS builds.

Root cause: Apple's paginated API responses include `links.next` with absolute
URLs like `https://developer.apple.com/services-account/v1/...`. In
ConnectResponse.fetchNextPageAsync(), these absolute URLs are passed directly
to axios. Because the URL is absolute, axios ignores the configured baseURL
(https://developer-mdn.apple.com), so the request hits developer.apple.com.
tough-cookie then rejects the session cookies (set for developer-mdn.apple.com)
causing the build to fail at capability/profile sync.

Fix: Normalize pagination URLs to relative paths (strip domain, keep path +
query) so axios always resolves them against the correct baseURL.

TypeScript source change needed in @expo/apple-utils:
  // Before
  getNextUrl(): string | null {
    return this.data?.links?.next ?? null;
  }

  // After
  getNextUrl(): string | null {
    const next = this.data?.links?.next ?? null;
    if (!next) return null;
    try {
      const parsed = new URL(next);
      return parsed.pathname + parsed.search;
    } catch {
      return next;
    }
  }

The postinstall script applies this fix to the compiled build/index.js until
@expo/apple-utils publishes a version with the fix included.

Closes expo#3392

Made-with: Cursor
@github-actions
Copy link

Subscribed to pull request

File Patterns Mentions
**/* @douglowder

Generated by CodeMention

- Run oxfmt to fix formatting issues in patch-apple-utils-pagination.js
- Add CHANGELOG entry under ## main > Bug fixes

Made-with: Cursor
@quinlanj
Copy link
Member

hey @adityapsbisht , thanks for putting up a fix! i've gone ahead and ported your fix to our internal apple-utils repo so we dont need to have a postinstall script to modify the minified code :) in the meantime, i'll leave this pr open until we've merged the changes upstream and bumped the deps!

@quinlanj
Copy link
Member

landed #3545

@quinlanj quinlanj closed this Mar 26, 2026
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.

Cookie domain mismatch in @expo/apple-utils pagination (developer-mdn.apple.com vs developer.apple.com)

2 participants