title: Spring boot security does not redirect after session expires
body: <p>I have been using spring boot, with spring security and Ext Js as frontend. I added this piece of code as configuration for spring security. It means that, when the session expires the user will be redirected to the referenced url, right?</p>
  
  <pre><code>@Override
  protected void configure(HttpSecurity http) throws Exception {
      http.cors().and()
              .authorizeRequests().antMatchers("/", "/login/**").permitAll().and()
              .authorizeRequests()
              .anyRequest().authenticated()
              .and()
              .formLogin()
              .loginPage("/login")
              .loginProcessingUrl("/userAuth")
              .permitAll()
              .and()
              .logout()
              .permitAll()
              .and()
              .authorizeRequests()
              .antMatchers(HttpMethod.POST, "/**").permitAll();
  
              http.csrf().disable();
              http.headers().frameOptions().disable();
  
              http.sessionManagement().maximumSessions(1).expiredUrl("/login?logout");
  }
  </code></pre>
  
  <p>Everytime my frontend sends an ajax request to spring, and the user has lost session, spring turns the request into a get request to /login?logout, as to be expected, but the page does not get redirected. All I can see is the login page on the response content of the request, without any effect on the page the user is seeing.</p>
  
  <p>Why does this happen? Am I missing any configuration or implementation here?</p>
  
  <p>EDIT: Here is what my Ext Js for the AJAX request looks like:</p>
  
  <pre><code>onAuthCheck: function (users) {
  
      var result = Ext.Ajax.request({
          url: '/Queue/requests/loginCheck',
          method: 'POST',
          async: false,
          params: {
              usersInfo: Ext.encode(users)
          },
          success: function (conn, response, options, eOpts) {
              console.log(response)
              console.log(conn.status);
              if (conn.status === 401 || conn.status === 302) {
                  location.href='/login?logout';
             }
          },
          failure: function (conn, response, options, eOpts) {
              console.log(response)
              console.log(conn.status)
              if (conn.status === 401 || conn.status === 302) {
                  location.href='/login?logout';
             }
          }
      })
      return (Ext.JSON.decode(result.responseText, true).success);
  },
  </code></pre>
  
  <p>EDIT2: Here is what my request looks like: It has a request with status 302, and still Im getting 200 status on my AJAX response on JS code.</p>
  
  <p><a href="https://i.stack.imgur.com/9FXNm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9FXNm.png" alt="enter image description here"></a></p>