title: How to set a custom header for webView requests in react-native
body: <p>I want to be able to detect on my ruby on rails server side that a http request has come from a webView component in my app. The app is using react-native. In particular, I want to distinguish between a request from the app and a request from mobile safari running on an ios device. </p>
  
  <p>I have tried setting the following in the <code>AppDelegate.m</code> file</p>
  
  <pre><code>  NSURL *url = [NSURL URLWithString:@"http://localhost:3000/signin"];
    NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60];
    [request addValue:@"GolfMentor" forHTTPHeaderField:@"User-Agent"];
    [request addValue:@"GolfMentor" forHTTPHeaderField:@"X-MY-CUSTOM-HEADER"];
    NSLog(@"%@", [request allHTTPHeaderFields]);
  </code></pre>
  
  <p>and the output in the console is</p>
  
  <pre><code>GolfMentor[63924:12437749] {
  "User-Agent" = GolfMentor;
  "X-MY-CUSTOM-HEADER" = GolfMentor;
  }
  </code></pre>
  
  <p>So the customer header appears to be set. However, when I view the request header in my ruby on rails app, there is no sign of the custom header. It looks like my changes are being overwritten latter in the execution of the react-native app.  So where and how should I set the custom header? I am also interested in do the same thing for an android version of the app?</p>