title: Spring boot single page application - forward every request to index.html
body: <p>I have a Spring Boot (v1.3.6) single page application (angular2) and i want to forward all request to the <code>index.html</code>.</p>
  
  <p>A request to <a href="http://localhost:8080/index.html" rel="noreferrer">http://localhost:8080/index.html</a> is working (200 and i get the index.html) but <a href="http://localhost:8080/home" rel="noreferrer">http://localhost:8080/home</a> is not (404).</p>
  
  <p>Runner.class</p>
  
  <pre><code>@SpringBootApplication
  @ComponentScan({"packagea.packageb"})
  @EnableAutoConfiguration
  public class Runner {
  
      public static void main(String[] args) throws Exception {
          ConfigurableApplicationContext run = SpringApplication.run(Runner.class, args);
      }
  }
  </code></pre>
  
  <p>WebAppConfig.class</p>
  
  <pre><code>@Configuration
  @EnableScheduling
  @EnableAsync
  public class WebAppConfig extends WebMvcConfigurationSupport {
  
      private static final int CACHE_PERIOD_ONE_YEAR = 31536000;
  
      private static final int CACHE_PERIOD_NO_CACHE = 0;
  
      @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
          registry.setOrder(-1);
          registry.addResourceHandler("/styles.css").addResourceLocations("/styles.css").setCachePeriod(CACHE_PERIOD_ONE_YEAR);
          registry.addResourceHandler("/app/third-party/**").addResourceLocations("/node_modules/").setCachePeriod(CACHE_PERIOD_ONE_YEAR);
          registry.addResourceHandler("/app/**").addResourceLocations("/app/").setCachePeriod(CACHE_PERIOD_NO_CACHE);
          registry.addResourceHandler("/systemjs.config.js").addResourceLocations("/systemjs.config.js").setCachePeriod(CACHE_PERIOD_NO_CACHE);
          registry.addResourceHandler("/**").addResourceLocations("/index.html").setCachePeriod(CACHE_PERIOD_NO_CACHE);
      }
  
  }
  </code></pre>
  
  <p><code>styles.css</code>, <code>/app/third-party/xyz/xyz.js</code>,.. are working (200 and i get the correct file). Only <code>/**</code> to <code>index.html</code> is not working.</p>