title: Spring Boot + Angular2 on same server
body: <p>I'm successfully integrated my Angular2 application with Spring Boot backend following <a href="https://blog.jdriven.com/2016/12/angular2-spring-boot-getting-started/" rel="noreferrer">this tutorial</a>, placing the compiled JS resources to a /ui subdirectory. Everything works fine basically, the Angular2 application is accessible through the <em>appname/ui</em> URL. </p>
  
  <p>However, I'd like to know if there is a way to tell Spring to 'pass-through' URLs that children of the <em>/ui</em> path, as currently Spring intercepts every requests targeting <em>/ui/*</em>, preventing the Angular2 Router properly navigating to resources under the <em>/ui</em> path.</p>
  
  <p>Currently, I only have this mapping in one of my controllers:</p>
  
  <pre><code>@RequestMapping(value = "/ui")
  public String uiIndex() {
      return "/ui/index.html";
  }
  </code></pre>
  
  <p>With this, the interface properly shows up at <em>/ui</em>, but Spring sends me errors and 404s for everything under it, <strong>when I address them directly from browser</strong>. Router navigation inside the Angular2 app works perfectly though.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I'm adding the compiled Angular2 resources from target/ui to static/ui folder with this config (my project uses maven build):</p>
  
  <pre><code>        &lt;resource&gt;
              &lt;directory&gt;${project.basedir}/src/main/resources&lt;/directory&gt;
              &lt;includes&gt;
                  &lt;include&gt;*.properties&lt;/include&gt;
                  &lt;include&gt;templates/*.*&lt;/include&gt;
              &lt;/includes&gt;
          &lt;/resource&gt;
          &lt;resource&gt;
              &lt;directory&gt;target/ui&lt;/directory&gt;
              &lt;targetPath&gt;static/ui&lt;/targetPath&gt;
          &lt;/resource&gt;
  </code></pre>
  
  <p>As to be clear, the only problem is, when I enter an URL in the browser like <em>/ui/home/settings</em>, Spring intercepts the request and throws errors. I can happily navigate to /ui, and then to /home/settings in the Angular context though.</p>