title: How to set up CORS or OPTIONS for Rocket.rs
body: <p>I've got a backend running rocket.rs which my flutter web app sends a request to, but it can't get past the OPTIONS response. </p>
  
  <p>I have tried adding CORS (rocket_cors) to the backend and having a options response, but it still sends back: </p>
  
  <pre><code>Error: XMLHttpRequest error.
      dart:sdk_internal 124039:30                           get current
  packages/http/src/browser_client.dart.lib.js 214:124  &lt;fn&gt;
  </code></pre>
  
  <p>I have added the following to my rocket project: </p>
  
  <pre class="lang-rust prettyprint-override"><code>#[options("/")]
  fn send_options&lt;'a&gt;(path: PathBuf) -&gt; Response&lt;'a&gt; {
      let mut res = Response::new();
      res.set_status(Status::new(200, "No Content"));
      res.adjoin_header(ContentType::Plain);
      res.adjoin_raw_header("Access-Control-Allow-Methods", "POST, GET, OPTIONS");
      res.adjoin_raw_header("Access-Control-Allow-Origin", "*");
      res.adjoin_raw_header("Access-Control-Allow-Credentials", "true");
      res.adjoin_raw_header("Access-Control-Allow-Headers", "Content-Type");
      res
  </code></pre>
  
  <p>And my flutter app is running this request: </p>
  
  <pre><code>Future&lt;String&gt; fetchData() async {
    final data2 = await http.get("http://my-web-site.com").then((response) { // doesn't get past here
      return response.body; 
    });
    return data2;
  }
  </code></pre>
  
  <p>Question: Is this the proper way to respond to OPTION requests, and if not, how can I implement it in rocket.rs?</p>