Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Headers not working #2089

Closed
hannojg opened this issue Jul 21, 2020 · 4 comments
Closed

[iOS] Headers not working #2089

hannojg opened this issue Jul 21, 2020 · 4 comments

Comments

@hannojg
Copy link
Contributor

hannojg commented Jul 21, 2020

Bug

I add to the video's source headers for authorization according to the docs: https://github.com/react-native-community/react-native-video#headers

        <Video
          style={styles.image}
          onLoadStart={(): void => setIsLoading(true)}
          onLoadEnd={(): void => setIsLoading(false)}
          source={{
            uri: resource.resources.highRes.url,
            //library seems to have incorrect typings, https://github.com/react-native-community/react-native-video#headers
            //@ts-expect-error
            headers: {
              Authorization: "Bearer " + authToken,
            },
          }}
        />

The video never loads, and when inspecting the network traffic I see 401: Unauthorized for the video requests. Also I can see that no authorization header is sent:
Screenshot 2020-07-21 at 09 28 21

Platform

Which player are you experiencing the problem on:

  • iOS
  • Android ExoPlayer
  • Android MediaPlayer
  • Windows UWP
  • Windows WPF

Environment info

React native info output:

System:
    OS: macOS 10.15.5
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 168.57 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 10.21.0 - /usr/local/opt/node@10/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/local/opt/node@10/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.6, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 23, 28, 29
      Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom, android-R | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6514223
    Xcode: 11.6/11E708 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_241 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0 
    react-native: 0.62.2 => 0.62.2 
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 4.4.5

Steps To Reproduce

Unfortunately, it's a bit hard to provide reproduction for this.
if it's absolutely needed I can create one.

Expected behaviour

The video loads and plays / auth header is attached to the request's headers.

@hannojg hannojg changed the title Headers not working [iOS] Headers not working Jul 21, 2020
@hannojg
Copy link
Contributor Author

hannojg commented Jul 21, 2020

Tested it on android everything works there. On real iOS device and simulator it doesn't.

@hannojg
Copy link
Contributor Author

hannojg commented Jul 21, 2020

also tried now with newest version 5.1.0-alpha6, still not working

@hannojg
Copy link
Contributor Author

hannojg commented Jul 21, 2020

Oh wow, I guess headers on iOS are disabled due to this: #1091

@hannojg
Copy link
Contributor Author

hannojg commented Jul 21, 2020

Oh wow, this is tricky. So back then you had to manually edit the RCTVideo.m (if your react-native-video version is < 5.1.0-alpha6).
However, there has recently been this PR merged: #2014 which seems to fix this issue (disabled header). But it ain't released yet. So to use it you have to install react-native-video from master

@hannojg hannojg closed this as completed Jul 21, 2020
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

No branches or pull requests

1 participant