title: SpringBoot with React - Rest API clashes with React Routes on refresh
body: <p>I am working on Spring Boot and React.</p>
  
  <p>I am exposing some REST APIs that will be consumed by the React app. </p>
  
  <p>In React I have user route</p>
  
  <p>Something like this </p>
  
  <pre><code>         &lt;Switch&gt;
              &lt;Route exact path="/" component={Home}&gt;&lt;/Route&gt;           
              &lt;PrivateRoute path="/profile" authenticated={this.state.authenticated} currentUser={this.state.currentUser}
                component={Profile}&gt;&lt;/PrivateRoute&gt;
              &lt;Route path="/login"
                render={(props) =&gt; &lt;Login authenticated={this.state.authenticated} {...props} /&gt;}&gt;&lt;/Route&gt;
              &lt;Route path="/signup"
                render={(props) =&gt; &lt;Signup authenticated={this.state.authenticated} {...props} /&gt;}&gt;&lt;/Route&gt;
              &lt;Route path="/oauth2/redirect" component={OAuth2RedirectHandler}&gt;&lt;/Route&gt;  
              &lt;Route component={NotFound}&gt;&lt;/Route&gt;
            &lt;/Switch&gt;
  </code></pre>
  
  <p>Endpoints:</p>
  
  <pre><code>http://localhost:3000/login
  http://localhost:3000/signup
  http://localhost:3000/dashboard
  </code></pre>
  
  <p>I have bundled both React and Spring Boot by adding these line in <code>pom.xml</code>  to run on a single port 8080</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;com.github.eirslett&lt;/groupId&gt;
      &lt;artifactId&gt;frontend-maven-plugin&lt;/artifactId&gt;
      &lt;version&gt;1.6&lt;/version&gt;
      &lt;configuration&gt;
          &lt;workingDirectory&gt;authserver-react&lt;/workingDirectory&gt;
          &lt;installDirectory&gt;target&lt;/installDirectory&gt;
      &lt;/configuration&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;id&gt;install node and npm&lt;/id&gt;
              &lt;goals&gt;
                  &lt;goal&gt;install-node-and-npm&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                  &lt;nodeVersion&gt;v8.11.3&lt;/nodeVersion&gt;
                  &lt;npmVersion&gt;5.6.0&lt;/npmVersion&gt;
              &lt;/configuration&gt;
          &lt;/execution&gt;
          &lt;execution&gt;
              &lt;id&gt;npm install&lt;/id&gt;
              &lt;goals&gt;
                  &lt;goal&gt;npm&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                  &lt;arguments&gt;install&lt;/arguments&gt;
              &lt;/configuration&gt;
          &lt;/execution&gt;
          &lt;execution&gt;
              &lt;id&gt;npm run build&lt;/id&gt;
              &lt;goals&gt;
                  &lt;goal&gt;npm&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                  &lt;arguments&gt;run build&lt;/arguments&gt;
              &lt;/configuration&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  
  &lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;phase&gt;generate-resources&lt;/phase&gt;
              &lt;configuration&gt;
                  &lt;target&gt;
                      &lt;copy todir="${project.build.directory}/classes/static"&gt;
                          &lt;fileset dir="${project.basedir}/authserver-react/build" /&gt;
                      &lt;/copy&gt;
                  &lt;/target&gt;
              &lt;/configuration&gt;
              &lt;goals&gt;
                  &lt;goal&gt;run&lt;/goal&gt;
              &lt;/goals&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>Once done I run build and <code>mvn spring-boot:run</code>  and open browser at <code>http://localhost:8080</code>  </p>
  
  <p>React comes in picture and redirect to <code>http://localhost:8080/login</code></p>
  
  <p>The problem is if I refresh the Page by clicking refresh button, Spring throws Whitelabel Error Page. </p>
  
  <p>This is happening because I have not defined any Controller with "/login". But I don't want to define that.</p>
  
  <p>Now I am not sure how do I differentiate React route with Spring APIs. </p>
  
  <p>I don't want to run React in a different port and Spring Boot in a different port. </p>