title: How to set authorization header in vue.js
body: <p>I'm making an axios post call with the JWT token generated after successful login. For all the requests I need to attach JWT token in header and in the back-end which is developed on spring -boot I have logic to get the token from header and validate it.</p>
  
  <p>From the browser, first the OPTIONS request goes to back-end where it gives me 403 error and in the back-end If I sysout headers, I can't find the header name X-XSRF-TOKEN</p>
  
  <pre><code>axios.post("http://localhost:8004/api/v1/auth", { "username": "test", "password" : "test"})
  .then((response) =&gt; {
      let token = response.data.token;
      axios.defaults.headers.common["X-XSRF-TOKEN"] = token;
      axios.post("http://localhost:8004/api/v1/getdata", {"action" : "dashboard"})
      .then((response) =&gt; {
          console.log(response.data);
      }, (error) =&gt; {
          console.log(error);
      })
  }, (error) =&gt; {
      console.log(error);
  })
  </code></pre>
  
  <p>Spring boot part</p>
  
  <pre><code>@Controller
  @CrossOrigin(origins = "*", allowedHeaders = "*")
  @RequestMapping(path = "/api/v1")
  public class ApplicationController {
      @PostMapping(path = "/getdata")
      @ResponseBody
      public SessionData getData(@RequestBody ProfileRequest profileRequest) {
          try {
              return profileService.getData(profileRequest);
          } catch (Exception e) {
              e.printStackTrace();
              return null;
          }
      }
  }
  </code></pre>