title: Custom headers for WebSocket JS
body: <p>I finding a simple solution to use WebSocket with custom headers for web app based on PHP as backend and js+vuejs as frontend.</p>
  
  <p>My app should connect to WebSocket server based on Java to get live stat. WebSocket server protected by Oauth2. So my app should add header like </p>
  
  <blockquote>
    <p>"Authorization: bearer 647d14-b132-41b9-aa4c-9eafad5d9630 "</p>
  </blockquote>
  
  <p>when connect to WS server. But i can't add this header because browser doesn't support custom headers. Answer on question about custom headers  <a href="https://stackoverflow.com/questions/4361173/http-headers-in-websockets-client-api">HTTP headers in Websockets client API</a></p>
  
  <p>I need something like code below</p>
  
  <pre><code>var serverWs = "ws://servername/stat"; var opts = { reconnection: false, transports: ['websocket'], extraHeaders: { 'Authorization': 'Bearer xxxx' } } var ws = new WebSocket(serverWs, opts);
  </code></pre>
  
  <p>What's solution exists?</p>