Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom HTTP Headers for WebView Requests

Tags:

react-native

Is it possible to modify the HTTP request headers of a React Native WebView component on iOS?

I'm aware of the onShouldStartLoadWithRequest function but this doesn't seem to allow any possibility for modification.

like image 975
Adam Terlson Avatar asked Dec 09 '15 14:12

Adam Terlson


1 Answers

You can put your request header on attribute headers like this:

<WebView source={{
  uri: "http://blog.apentle.com/",
  headers: {
    Authorization: "Basic YXBlbnRsZS5jb206YXBlbnRsZQ==",
  }
}}
style={styles.webview} />
like image 164
DoanND Avatar answered Nov 15 '22 16:11

DoanND