You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experimenting with microservices architecture and I have an issue. I have a Zuul gateway and client web application with login form and controllers inside in zuul gateway. Routes to the microservices are defined in Zuul application.yaml config. Microservices also register them selves to eureka server. Users is authenticated against database using jdbcAuthentication. When user enters http://localhost:8080 address in browser zuul displays login form. After successful login user is redirected to home page (index) controller. This controller additionally executes RestTemplate call to the user-info microservice that is under zuul proxy with address http://localhost:8080/user/ defined in config as /user route. Then instead of json response from microservice I am getting same login form html code. If I try to access http://localhost:8080/user/ rest endpoint from browser then I get a nice and clear object with attributes in JSON response. It looks like that RestTemplate losts or doesn't pass authentication or session information. I am adding my config code examples
@ControllerpublicclassIndexController{
@AutowiredprivateRestTemplaterestTemplate;
@RequestMapping("/")
publicStringindex(ModelMapmodel, HttpServletRequestrequest, HttpServletResponseresponse) {
LonguserId = 2L;
Stringuser = restTemplate.getForObject("http://localhost:8080/user/find/{id}", String.class, userId);
// this is the place where I get html code of login form instead of JSONreturn"index";
}
}
I am experimenting with microservices architecture and I have an issue. I have a Zuul gateway and client web application with login form and controllers inside in zuul gateway. Routes to the microservices are defined in Zuul application.yaml config. Microservices also register them selves to eureka server. Users is authenticated against database using jdbcAuthentication. When user enters http://localhost:8080 address in browser zuul displays login form. After successful login user is redirected to home page (index) controller. This controller additionally executes RestTemplate call to the user-info microservice that is under zuul proxy with address http://localhost:8080/user/ defined in config as /user route. Then instead of json response from microservice I am getting same login form html code. If I try to access http://localhost:8080/user/ rest endpoint from browser then I get a nice and clear object with attributes in JSON response. It looks like that RestTemplate losts or doesn't pass authentication or session information. I am adding my config code examples
ZUUL config
Zuul client web app controller controller
User microservice rest controller
I hope that I clearly explained my situation. Thanks for help in advance.
The text was updated successfully, but these errors were encountered: