facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
117.75k stars 24.16k forks source link

`headers` defined in Image `source` prop are not sent along with the request for a remote image #45404

Open pklatka opened 1 month ago

pklatka commented 1 month ago

Description

When defining a headers object in source prop in Image component, the custom headers are not passed to the http request (on iOS platform). On the old architecture everything works correctly.

Steps to reproduce

  1. Clone the reproducer
  2. Install project dependencies with npm
  3. Run the app with npm run ios
  4. Run the server with npm run server
  5. Observe logs on a server - custom headers are not set when requesting a remote image

React Native Version

0.74.3

Affected Platforms

Runtime - iOS

Areas

Fabric - The New Renderer

Output of npx react-native info

System:
  OS: macOS 14.5
  CPU: (11) arm64 Apple M3 Pro
  Memory: 73.56 MB / 18.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.11.1
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.21
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.4
    path: /usr/local/bin/npm
  Watchman:
    version: 2024.07.08.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.15989.150.2411.11948838
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 18.0.2
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.3
    wanted: 0.74.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

This issue does not produce a crash.

Reproducer

https://github.com/pklatka/image-source-headers-obj-repro

Screenshots and Videos

No response

deepanshushuklad11 commented 1 month ago

@cortinico Raised a PR for the same , please have a look

pafry7 commented 1 month ago

@deepanshushuklad11 @pklatka Do headers work on Android?

pklatka commented 1 month ago

On Android this works properly.