'Login page is not displayed - Angular 12 / Zuul Gateway
I have angular app (port 4200) that communicate with Zuul spring boot gateway (port 7575). Gateway communicate with one spring boot app (port 8182) to find employe.
I have implemented spring security config in zuul whit userDetailsService.
Problem :
If I make the request from gateway :
Exemple : http://localhost:7575/api/employe/name/myname, I'm connected, so I am redirected to this page (http://localhost:7575/login) : default login page with spring boot security, so it's good
But, If I make the request from my angular App (I click on one button that call gateway and gateway redirect to the good service), I have in js console :
And login page is not displayed.
Code Angular :
public findEmployeeByName(employeeName: string) : Observable<Employe | undefined> {
return this.http.get<Employe>('http://localhost:7575/api/employe/name/' + employeeName);
}
Code Zuul :
http.cors().and()
.formLogin()
.and()
.httpBasic()
.and()
.logout().permitAll().logoutSuccessUrl("/login").and().
authorizeRequests()
.antMatchers("/**").hasAnyRole("ADMIN")
.antMatchers("/login").hasAnyRole("ADMIN")
.antMatchers(HttpMethod.GET, "/api/employe/name/**").hasAnyRole("ADMIN")
.anyRequest().authenticated()
.and().csrf().disable();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
