title: How to solve flutter web api cors error only with dart code?
body: <p>It seems like CORS error is well-known issue in the web field. But I tried flutter web for the first time ever and I faced critical error.</p>
  <p>The code below worked well in app version when it was running on iOS device, but when i tested the same code on Chrome with web debugging from beta channel, it encountered CORS error.</p>
  <p>Other stackoverflow answers explained how to solve the CORS issue with serverside files of their projects. But I have totally no idea what is server thing and how to deal with their answers. The error message from Chrome console was below</p>
  <p>[  Access to XMLHttpRequest at 'https://kapi.kakao.com/v1/payment/ready' from origin 'http://localhost:52700' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.  ]</p>
  <p>So, what i want to do is to solve above 'Access-Control-Allow-Origin header' issue ONLY WITH DART CODE! Code below is what i've tried to solve these issues only with my main.dart.</p>
  <pre><code>onPressed: () async {
        var res =
            await http.post('https://kapi.kakao.com/v1/payment/ready', encoding: Encoding.getByName('utf8'), headers: {
          'Authorization': 'KakaoAK $_ADMIN_KEY',
          HttpHeaders.authorizationHeader: 'KakaoAK $_ADMIN_KEY',
          &quot;Access-Control-Allow-Origin&quot;: &quot;*&quot;,
          &quot;Access-Control-Allow-Methods&quot;: &quot;POST, GET, OPTIONS, PUT, DELETE, HEAD&quot;,
        }, body: {
          'cid': 'TC0ONETIME',
          'partner_order_id': 'partner_order_id',
          'partner_user_id': 'partner_user_id',
          'item_name': 'cool_beer',
          'quantity': '1',
          'total_amount': '22222',
          'vat_amount': '2222',
          'tax_free_amount': '0',
          'approval_url': '$_URL/kakaopayment',
          'fail_url': '$_URL/kakaopayment',
          'cancel_url': '$_URL/kakaopayment'
        });
        Map&lt;String, dynamic&gt; result = json.decode(res.body);
        print(result);
      },
  </code></pre>
  <p>Even though i actually had the header <code>&quot;Access-Control-Allow-Origin&quot;: &quot;*&quot;</code> which most other answers recommended, the Chrome console printed same error message. Weird thing is that the same code made successful request in mobileApp version. So I think this is only problem with flutter WEB VERSION.</p>
  <p>Hope somebody can figure it out and suggest only-dart code to resolve the issue in my main.dart!! Thank you for reading [:</p>