title: Angular 6 (Frontend) + Spring: Configuring Routing
body: <p>I've created a Spring project with Angular 6 (front-end) and Kotlin/Java (back-end). I followed <a href="http://javasampleapproach.com/spring-framework/spring-boot/kotlin-spring-boot/integrate-angular5-kotlin-springboot-springtoolsuite" rel="nofollow noreferrer">JavaSampleApproach's tutorial</a> (except, instead of Maven, I use Gradle).</p>
  
  <p>On Angular, I followed <a href="https://angular.io/guide/router" rel="nofollow noreferrer">Angular's routing guide</a>. This is how I set up my routes:</p>
  
  <pre><code>const routes: Routes = [
    {path: 'clients', component: ClientsComponent},
    {path: 'scopes', component: ScopesComponent},
    {path: 'identity-providers', component: IdentityProvidersComponent},
    {path: 'diagnostics', component: DiagnosticsComponent},
    {path: '', redirectTo: '/clients', pathMatch: 'full'}
  ];
  </code></pre>
  
  <p>From there, I first run <code>ng serve</code> on port 8080, which works perfectly.</p>
  
  <p>Then, I run <code>ng build --prod</code>, which builds it into the Spring project folder.</p>
  
  <p>In my <code>src/main/kotlin/com.example.myproject</code> directory, I created a <strong>ViewController</strong> class based on <a href="https://stackoverflow.com/questions/38516667/springboot-angular2-how-to-handle-html5-urls?noredirect=1&amp;lq=1">@AndroidLover 's response</a>:</p>
  
  <pre><code>package com.example.platformadmintool
  
  import org.springframework.web.bind.annotation.RequestMapping
  import org.springframework.web.bind.annotation.RestController
  
  @RestController
  class ViewController {
  
      @RequestMapping("/clients", "/scopes", "/identity-providers", "/diagnostics")
      fun routing() : String {
          return "forward:/index.html"
      }
  }
  </code></pre>
  
  <p>(I do understand that @AndroidLover 's response was meant for Angular 2.)</p>
  
  <p>When I run the gradle commands <code>clean build bootRun</code>, the front page loads when I type "<a href="http://localhost:8080" rel="nofollow noreferrer">http://localhost:8080</a>". I am able to traverse to "<a href="http://localhost:8080/diagnostics" rel="nofollow noreferrer">http://localhost:8080/diagnostics</a>" and other pages cleanly through clicking the navs. </p>
  
  <p>However, if I explicitly type in the route, like "<a href="http://localhost:8080/clients" rel="nofollow noreferrer">http://localhost:8080/clients</a>", all the page displays is <code>forward:/index.html</code> in text form. </p>
  
  <p>Obviously, the error is in my request mappings. I'm guessing it has to do with me returning a String, but most solutions online seem to use <code>forward:/index.html</code>.</p>
  
  <p>I am not too familiar to with Spring and integrating it with Angular 6. How do I configure my routes to work also in Spring?</p>
  
  <p><strong>EDIT</strong>: <a href="https://stackoverflow.com/questions/47564695/spring-boot-angular-entering-url-in-address-bar-results-in-404?rq=1">Similar problem</a></p>