Skip to content

fix(image): preserve source headers with crossOrigin and referrerPolicy - #58319

Closed
mfkrause wants to merge 2 commits into
react:mainfrom
mfkrause:fix/image-source-header-merging
Closed

fix(image): preserve source headers with crossOrigin and referrerPolicy#58319
mfkrause wants to merge 2 commits into
react:mainfrom
mfkrause:fix/image-source-header-merging

Conversation

@mfkrause

@mfkrause mfkrause commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary:

When crossOrigin="use-credentials" or referrerPolicy is used on an Image, getImageSourcesFromImageProps currently fully replaces source.headers, removing custom headers such as Authorization.

This fix merges the generated headers with the user-provided source headers instead (generated headers take precedence).

Changelog:

[GENERAL] [FIXED] - Preserve Image source headers when using crossOrigin or referrerPolicy

Test Plan:

Confirmed existing tests are unchanged & added a regression test

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 3, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 3, 2026
Comment thread packages/react-native/Libraries/Image/ImageSourceUtils.js Outdated
@mfkrause
mfkrause requested a review from javache September 4, 2026 10:57
@meta-codesync

meta-codesync Bot commented Sep 4, 2026

Copy link
Copy Markdown

@javache has imported this pull request. If you are a Meta employee, you can view this in D118797893.

@javache

javache commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

generated headers take precedence

Any reason you went with this? Wouldn't the headers in the URI be more specific?

@mfkrause

mfkrause commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@javache To preserve existing behavior for conflicting names. The current implementation replaces source.headers completely. This fix preserves this behavior for the conflicting names, while preserving other (unrelated) source headers.

I agree that the better / more correct design would be to have user-supplied source headers take precedence, however. Happy to reverse that order if you'd prefer

@meta-codesync meta-codesync Bot closed this in 08c7781 Sep 4, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Sep 4, 2026
@meta-codesync

meta-codesync Bot commented Sep 4, 2026

Copy link
Copy Markdown

@javache merged this pull request in 08c7781.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants