title: Angular httpclient CORS request returns 404 error
body: <p>I started a sample Angular application that runs on 127.0.0.1:4200 (PC A),  I started a web browser at the same computer and everything works fine.</p>
  
  <p>In the application, there is a heroService.ts that calls this.http.get etc to get the data from 127.0.0.1:4200.</p>
  
  <p>I then started another http server using nodejs express which provides some API services, the IP is 192.168.2.101:3000 (PC B). The api is perfectly fine because I can run it in any web browser and see the results (all in json). In nodejs express, I installed cors too and use app.use(cors()) to enable CORS support.</p>
  
  <p>The following is where the problem is.</p>
  
  <p>I followed heroService.ts in PC A, and created apiService.ts, and use <code>this.http.get("http://192.168.2.101:3000").subscribe(_=&gt;console.log("ok"));</code> to call the API at PC B (PC B should already have cors enabled).</p>
  
  <p>However, it seems that Angular running at browser cannot identify this address, and in browser's debug window, I can see 404 error, <a href="http://192.168.2.101:3000" rel="nofollow noreferrer">http://192.168.2.101:3000</a> cannot be found. Note that the same url <a href="http://192.168.2.101:3000" rel="nofollow noreferrer">http://192.168.2.101:3000</a> works perfectly in web browser directly.</p>
  
  <p>The weird thing is that in the browser's (chrome and edge) network debug window, I could not see any request was sending out, there's no such request sent to the server. And at the nodejs's server side, I tried to log any connections and I could not see any too. It seemed to me that the web browser didn't send this http get out, and the angular library returned 404 directly.</p>
  
  <p>I tried to search the same error but could not find anything useful.</p>
  
  <p>I would guess that Angular's library will keep using the base url (127.0.0.1:4200) and will not parse <a href="http://192.168.2.101:3000" rel="nofollow noreferrer">http://192.168.2.101:3000</a> ? Is there a way to solve it?</p>
  
  <p>I hope I explained the problem clearly.</p>
  
  <p>Thanks for help.</p>