title: Images uploaded with Node server cannot be found by Angular 2
body: <p>I have an app in Angular 2, decided to add real server, Node JS, to upload documents and do other things. </p>
  
  <pre><code>Browser =&gt; Angular [localhost:4200/api/documents] =&gt; Node [localhost:3000/documents]
  </code></pre>
  
  <p>This is how I start them together using <strong>scripts</strong> in <strong>package.json</strong></p>
  
  <pre><code>"scripts": {
      "server-start": "gulp",
      "client-start": "ng serve --verbose --proxy-config server.conf.json",
      "start": "npm-run-all -p client-start server-start"
  }
  </code></pre>
  
  <p>So, when I run npm start it starts 2 parallel processes - Node JS using Gulp and Angular using ng serve. Angular is a front end, but all URLs that start with <strong>/api</strong> get redirected to Node. Here is how it's done with <strong>server.config.js</strong></p>
  
  <pre><code>{
    "/api": {
      "target": "http://localhost:3000",
      "secure": false
    }
  }
  </code></pre>
  
  <p>Node JS receives stream from Angular with image and saves it in Angular assets folder, so uploaded image should be available in Angular, but when I try to open uploaded image in browser it returns me 404, not found. Just in case, this is part of my <strong>.angular-cli.json</strong></p>
  
  <pre><code>"root": "src",
  "outDir": "dist",
  "assets": [
    "assets",
    "favicon.ico",
    "service-worker.js"
  ],
  "index": "index.html",
  "main": "main.ts"
  </code></pre>
  
  <p>Example, I have existing image that was there before <strong>ng serve</strong></p>
  
  <pre><code>F:\Node\cms\src\assets\uploads\1.jpg
  </code></pre>
  
  <p>available at, it works</p>
  
  <pre><code>http://localhost:4200/assets/uploads/1.jpg
  </code></pre>
  
  <p>I upload new one to the same location</p>
  
  <pre><code>F:\Node\cms\src\assets\uploads\5.jpg
  </code></pre>
  
  <p>but it's NOT available at</p>
  
  <pre><code>http://localhost:4200/assets/uploads/5.jpg
  </code></pre>
  
  <p>When I restart my servers image becomes available. According to <a href="https://github.com/angular/angular-cli/issues/5268" rel="nofollow noreferrer">this discussion</a> <strong>ng serve</strong> performs deployment of Angular app in the background, and folder dist is empty, all images are taken from memory, and any new images dropped into assets won't be available, correct me if I am wronng.</p>
  
  <p><strong>Question #1:</strong> is built-in Angular server able to handle dynamic images if they were added when application is already running in memory?</p>
  
  <p><strong>Question #2:</strong> looks like in complex apps <strong>ng serve</strong> brings more troubles than benefits, is it worth to try to make it working or you'd recommend to start using <strong>ng build</strong> instead?</p>