title: Angular 2 HTTP GET 404 Not Found for URL
body: <p>I am trying to integrate Angular 2 application with Java Spring Boot backend. For the moment, I place my Angular 2 files under <code>src/main/resources/static</code> (meaning both Angular and Spring apps run witin the same app on the same port).</p>
  
  <p>I am trying to do HTTP GET like this:</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { Http } from '@angular/http';
  import { Language } from '../model/language';
  import { Observable } from 'rxjs/Rx';
  import 'rxjs/add/operator/catch';
  import 'rxjs/add/operator/map';
  
  @Injectable()
  export class LanguageService {
  
      constructor(private http: Http) { }
  
      private langUrl = 'api/languages'; 
  
      getLanguages() : Observable&lt;Language[]&gt; {
           return this.http.get(this.langUrl)
                           .map((res:Response) =&gt; res.json())
       }
  }
  </code></pre>
  
  <p>I have intentionally removed error handling code from get, because it leads to misleading error.
  What I get is:</p>
  
  <pre><code>Error: Uncaught (in promise): Error: Error in :0:0 caused by: Response with status: 404 Not Found for URL: api/languages
  Error: Error in :0:0 caused by: Response with status: 404 Not Found for URL: api/languages
      at ViewWrappedError.BaseError [as constructor] (http://localhost:8000/node_modules/@angular/core/bundles/core.umd.js:1179:31) [angular]
      at ViewWrappedError.WrappedError [as constructor] (http://localhost:8000/node_modules/@angular/core/bundles/core.umd.js:1232:20) [angular]
      at new ViewWrappedError (http://localhost:8000/node_modules/@angular/core/bundles/core.umd.js:6552:20) [angular]
  //more output here - will provide full stack trace if needed
  </code></pre>
  
  <p>The URL <code>http://localhost:8080/api/languages</code> is handled by Java Spring controller and it works if I do GET via Postman or Web Browser.</p>
  
  <p>My impression is that 404 Error did not come from server, because:</p>
  
  <ul>
  <li>I don't see any activity in the server logs  </li>
  <li>I get the same result regardless if server side is up or down.</li>
  </ul>
  
  <p>I think there is something wrong with my Angular 2 configuration, but I don't find any tips in documentation. </p>
  
  <p>I tried different urls, like <code>http://localhost:8080/api/languages</code>, <code>/api/languages</code>, <code>api/languages</code>, <code>another/working/server/endpoint</code> - all lead to the same error. </p>
  
  <p>I have even tried to use JSONP as described <a href="https://stackoverflow.com/questions/36289495/how-to-make-a-simple-jsonp-asynchronous-request-in-angular-2">here</a>, but I got a different issue that JSONP was not injected to the Language Service constructor (that issue is a different topic, I guess).</p>
  
  <p>I have found a <a href="https://stackoverflow.com/questions/40824847/404-not-found-angular-2-cant-talk-to-spring-rest-api">similar question</a>, but it was never answered so far.</p>
  
  <p>If you have any ideas how to fix this issue or experienced the similar problem - any help or comment will be highly appreciated.</p>
  
  <p>Thank you</p>