title: single bundeled springboot/angular - cross-domain application, how to get back to specific angular state after jumpback from other domain?
body: <p>I have an App which consists of a local &quot;web app&quot; with an angular front end and a local spring boot back end bundeled together running on the same port.</p>
  <p>Everything works fine until i need to leave the page and jump back:</p>
  <p>The user has to do a log in on an external server.</p>
  <p>After the log in, he/she jumps back to the local app. the jumpback-url triggers a controller in the local spring boot part of the application. the problem now is to get back to the angular-routes from there on, as the spring boot controller are triggred instead of the controllers and routes defined on the angular app-page.</p>
  <p>i would need to continue the execution of the front end code in angular, an my problem is how to get back to the angular code from the spring boot code, where i landed now after the jumpback (the jumpback uri is my host with the port, where the application is running)</p>
  <p>Backend controller after jumpback:</p>
  <pre><code>    @PostMapping(path = &quot;/*someEndpoint*&quot;)
      public Object processResponse(@RequestBody @JsonProperty String requestBody) throws InternalServerException, ExecutionException, InterruptedException {
  
   ModelAndView *resultView* = *someService*.dispatchResponse(requestBody);
  
          return resultView;
      }
  </code></pre>
  <p>Attempt to redirect, only working to get to the root page (this below works) but i would need to route to more specific urls, defind in angular, e.g. &quot;/someotherendpoint&quot; or so. but then the error message: &quot;whitelabel error page - this application has no explicit mapping for /error, so you see this as a fallback&quot; appears, because i have no controller defined named &quot;/someotherendpoint&quot; in the spring boot part, only in the angular part.</p>
  <pre><code>@Component
  public class RedirectService {
  
      RestTemplate confirmed;
  
      public ModelAndView redirectToStartPage() {
  
          return new ModelAndView(&quot;redirect:/&quot;);
      }
  </code></pre>
  <pre><code>    public ModelAndView dispatchResponse(String jsonResponse) throws InternalServerException, ExecutionException, InterruptedException {
          
          ModelAndView returnPage = redirectService.redirectToStartPage();
  
          return returnPage;
      }
  </code></pre>
  <p>Frontend code in anglular, where the jump to the external domain with a java-script form-action is conducted:</p>
  <pre><code>
    post(body, url){
      var mapForm = document.createElement('form');
  
      mapForm.enctype = 'text/plain';
      mapForm.method = 'POST';
      mapForm.action = url;
  
      // define input element w data to submit in request body
      var mapInput = document.createElement('input');
      mapInput.type = 'hidden';
      mapInput.name = 'data';
      mapInput.setAttribute('value', body);
      mapInput.setAttribute('id', 'data');
      mapInput.setAttribute('type', 'textarea');
      mapForm.appendChild(mapInput);
      document.body.appendChild(mapForm);
      mapForm.submit();
  
    
    }
  
  </code></pre>
  <p>Funcion in javascript which is triggered after pressing the button on the angular-frontend where the jump the external page happens</p>
  <pre><code>  applySTH(): void {
      let message: string;
  
      this.someService
        .*methodName*(this.*someOtherService*.*getSomeVariables*())
        .pipe(
          map((response: *someVariable*) =&gt; {
          *some assigning*
          })
        )
        .subscribe(
          (data) =&gt; {
         *some handling*
            });
            this.logger.info(message);
  
            let reqBody = {
              '*some-data*
            };
            this.redirectToExternalHost(reqBody);
          },
          (err) =&gt; {*handling*
              }
            );
            this.notification.openDialog(NgxLoggerLevel.ERROR, message);
          }
        );
    }
  
    // Method to redirect to Page on *&lt;host&gt;* with Post-Request
  
    redirectToExternalHost(reqBody: Object): any {
      let data = *someData*;
  
      this.*someService*.post(data, this.*someService*.*uri*);
    }
  </code></pre>
  <p>how can i pass back control /redirect to the front end code where i called the extarnal page? or redirect to another angular page (url , route defined in angular)</p>
  <p>because i cannot adress simply the pages and urls and routing defined in angular, as the browser keeps talking to the back-end at this point, expecting controllers in the back-end to listen.</p>
  <p>does anyone knows solution? many thanks in Advance!</p>