I'm having problems establishing session between Angular 9 and Spring Boot.
When call localhost:8080/test
I always get same SessionId
from the server.
However, when I call the same endpoint via Angular 9,
this.http.get('localhost:8080/test').subscribe()
I get each call different SessionId. Why?
WebSecurityConfig.java
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)
.and()
.csrf()
.and()
.cors().disable()
.authorizeRequests()
.antMatchers("/test").permitAll()
.anyRequest().authenticated()
}
TestEndpoint.java
@RestController
@Slf4j
public class TestEndpoint {
@Autowired
HttpSession session;
@GetMapping("/test")
public void test(){
log.info(session.getId());
}
}