'How to handle redirect in Spring Boot and Angular

I am getting a redirect request with Authrozation_code from ADFS on my Spring Boot controller. I am able to fetch tokens using the code and post that I need to redirect to my angular client with the tokens.

I have written below code in my Spring Boot controller which successfully redirect to my angular UI with 304 status code and headers set as below

public void login(String code, HttpServletRequest request, HttpServletResponse response){
  response.addHeader("id_token", id_token);
  response.sendRedirect(angularURL);
}

May I know what is the ideal way to redirect to Angular UI from Spring Boot rest controller? Because I want my angular client to read the tokens from the headers once it redirect on it and call the next APIs. Because it's difficult for Angular client to read the headers if it gets 304 as a status code.

Note: I can redirect with below code also but that will expose the token and the URI will be large.

response.sendRedirect(angularURL + id_token);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source