title: How to add dynamic header to the request send from react app
body: <p>I am passing cookie details from the react like the following way:</p>
  <pre><code>export const userAuthStatus = async () =&gt; {
   let authStatus = [];
   authStatus = axios.post('https://../auth_status', { resources: [{ classpath: 'test }] },
    { withCredentials: true }).then(response =&gt; response.data.user);
  
    return authStatus;
  };
  </code></pre>
  <p>And my backend service has been written in Springboot. I am getting the cookie(origin) in my spring boot application using the following code.</p>
  <pre><code>   request.getHeader(&quot;origin&quot;)
  </code></pre>
  <p>But I need to add a particular cookie value as a header in a request.</p>
  <pre><code>  curl -X GET &quot;http://.../authstatus&quot; -H &quot;origin:&quot;value&quot;
  </code></pre>
  <p>But now I am getting like curl -X GET &quot;http://.../authstatus&quot; -H &quot;accept: <em>/</em>&quot;</p>
  <p>Here I have added the following CORSFilter</p>
  <pre><code>@Component
  </code></pre>
  <p>@Configuration
  public class CorsFilter extends OncePerRequestFilter
  {</p>
  <pre><code>String authStatusCheckUrl = &quot;https://..../autthenticate&quot;;
  @Override
  protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
      String origin = request.getHeader(&quot;origin&quot;);
      response.setHeader(&quot;Access-Control-Allow-Origin&quot;, origin);
      response.setHeader(&quot;Access-Control-Allow-Methods&quot;, &quot;GET, POST, PUT, DELETE, OPTIONS&quot;);
      response.setHeader(&quot;Access-Control-Max-Age&quot;, &quot;3600&quot;);
      response.setHeader(&quot;Access-Control-Allow-Headers&quot;, &quot;authorization, content-type, xsrf-token, X-Auth-Token, X-App-Token, X-App-Version, X-App-Env&quot;);
      response.setHeader(&quot;Access-Control-Allow-Credentials&quot;, &quot;true&quot;);
      response.setHeader(&quot;Access-Control-Expose-Headers&quot;, &quot;X-Auth-Token&quot;);
      if (origin != null)
      {
          HttpStatus statuscode = AuthController.checkUserAuth(request.getHeader(&quot;origin&quot;), authStatusCheckUrl);
          if(statuscode.equals(HttpServletResponse.SC_OK)){
              response.setHeader(&quot;Set-Cookie&quot;, request.getHeader(&quot;at_origin&quot;));
          }
      }
      else {
          filterChain.doFilter(request, response);
      }
      }
  
   }
  </code></pre>
  <p>How can add a header for each request sent from react. (In react, I can't specify the Header, I have to send only {withCredentials:true} but while doing the request I need to add a specific header</p>