title: CORS problem,using axios,how can this be possible?
body: <p>I'm using gin to be my backend,and this is my cors middleware code.</p>
  <pre class="lang-golang prettyprint-override"><code>func Cors() gin.HandlerFunc {
      return func(ctx *gin.Context) {
          method := ctx.Request.Method
          if method == &quot;OPTIONS&quot; {
              ctx.Header(&quot;Access-Control-Max-Age&quot;, &quot;1728000&quot;)
              ctx.Header(&quot;Access-Control-Allow-Credentials&quot;, &quot;true&quot;)
              ctx.Header(&quot;Access-Control-Allow-Methods&quot;, &quot;GET,PUT,POST,DELETE,PATCH,OPTIONS&quot;)
              ctx.Header(&quot;Access-Control-Allow-Headers&quot;, &quot;Content-Type,Cookie,Authorization,Access-Control-Request-Headers,Access-Control-Request-Method,Origin,Referer,Sec-Fetch-Dest,Accept-Language,Accept-Encoding,Sec-Fetch-Mode,Sec-Fetch-Site,User-Agent,Pragma,Host,Connection,Cache-Control,Accept-Language,Accept-Encoding,X-Requested-With,X-Forwarded-For,X-Forwarded-Host,X-Forwarded-Proto,X-Forwarded-Port,X-Forwarded-Prefix,X-Real-IP,Accept&quot;)
              ctx.Header(&quot;Access-Control-Allow-Origin&quot;, ctx.Request.Header.Get(&quot;origin&quot;))
              ctx.AbortWithStatus(http.StatusNoContent)
              return
          }
          ctx.Next()
      }
  }
  </code></pre>
  <p>In the frontend,I'm using the axios to request,and I'm using React to develop my app.<br />
  Below is my setting about axios.</p>
  <pre class="lang-js prettyprint-override"><code>const BASE_URL = &quot;http://localhost:8000&quot;;
  
  axios.defaults.baseURL = BASE_URL;
  axios.defaults.withCredentials = true;
  </code></pre>
  <p>and I abstracted a function to do a POST request</p>
  <pre class="lang-js prettyprint-override"><code>async function post&lt;T = any, D = any&gt;(
      url: string,
      data?: T,
      headers?: AxiosRequestHeaders
  ): Promise&lt;D&gt; {
      const res = await axios.post(url, data, {
          headers: headers,
      });
      if (res.status === 200) return Promise.resolve(res.data);
      else return Promise.reject(res.statusText);
  }
  </code></pre>
  <p>it's interesting when I requesting on Chrome.</p>
  <p><a href="https://i.stack.imgur.com/fcn7X.png" rel="nofollow noreferrer">picture</a></p>
  <p>I truly got a Access-Control-Allow-Origin header but it just said I didn't get this header in respond.</p>
  <p>It's really weired and I don't know how to do.</p>