title: React + Spring | Authentication always fails with axios.post but it is working with axios.get
body: <p>I have an Authentication filter in my rest API. </p>
  
  <p>SecuritfyConfig:</p>
  
  <pre><code>@Autowired
  private CustomTokenAuthentication authProvider;
  
  @Override
  protected void configure(AuthenticationManagerBuilder auth) throws Exception
  {
      auth.authenticationProvider(authProvider);
  }
  
  @Override
  protected void configure(HttpSecurity http) throws Exception
  {
      http.cors().and().authorizeRequests().anyRequest().authenticated().and().httpBasic();
  }
  </code></pre>
  
  <p>CustomTokenAuthentication:</p>
  
  <pre><code>EmployeeService employeeService;
  public CustomTokenAuthentication(EmployeeService employeeService)
  {
      this.employeeService = employeeService;
  }
  
  @Override
  public Authentication authenticate(Authentication authentication) throws AuthenticationException
  {
  
      String name = authentication.getName();
      String sessionKey = authentication.getCredentials().toString();
      System.out.println(name + " | " + sessionKey);
  
      if(employeeService.checkSessionKey(sessionKey))
      {
          System.out.println("access granted");
          // use the credentials
          // and authenticate against the third-party system
          return new UsernamePasswordAuthenticationToken(name, sessionKey, new ArrayList&lt;&gt;());
      } else
      {
          System.out.println("access not granted");
          return null;
      }
  }
  
  @Override
  public boolean supports(Class&lt;?&gt; authentication)
  {
      return authentication.equals(UsernamePasswordAuthenticationToken.class);
  }
  </code></pre>
  
  <p>Now if I want to access some Data from the frontend I use this Axios Command:</p>
  
  <pre><code>axios.get("https://localhost:8443/components",  {
    auth: {
      username: "user",
      password: this.getCookie("session_key")
    },})
      .then(response =&gt; {
        const components = response.data;
        this.setState({components})
      })
  </code></pre>
  
  <p>This axios.get works fine. If I try the same with axios.post I doesn't work. I know that the post has another Syntax then the Get but it still does not work:</p>
  
  <pre><code>    axios.post('https://localhost:8443/filter', {
            node: this.state.filterNodes,
            service: this.state.filterServices,
            component: this.state.filterComponents
          },
    {
      auth: {
        username: 'user',
        password: this.getCookie("session_key")
      }
      }).then(response =&gt; {
        const applications = response.data;
        this.setState({applications})
      })
  </code></pre>
  
  <p>I get this error in my Console:</p>
  
  <pre><code>POST https://localhost:8443/filter 401
  </code></pre>
  
  <p>When I ignore this specific URL in the Config it works fine. But it should also go throught Authentication.</p>