title: How to make a proxy for my backend for my angular app during the dev?
body: <p>I'm trying to make sure that every browser call to an URL that is inside the &quot;api&quot; path is redirect to another (dev) server.</p>
  <p>So it would mean that when my angular app is requesting :</p>
  <p>https://localhost:4200/api/some/feature --&gt; https://localhost:7276/api/some/feature should be requested</p>
  <p>This has to take all the sub-folder of /api and also forward the GET attributes.</p>
  <p>I've found this <a href="https://angular.io/guide/build#proxying-to-a-backend-server" rel="nofollow noreferrer">documentation</a> which seems to do exactly what I'm asking.</p>
  <p>I've created the proxy.config.json:</p>
  <pre><code>{
    &quot;/api/*&quot;: {
      &quot;target&quot;: &quot;https://localhost:7276/&quot;,
      &quot;secure&quot;: &quot;true&quot;,
      &quot;logLevel&quot;: &quot;debug&quot;
    }
  }
  </code></pre>
  <p>modified the angular.json:</p>
  <pre><code>&quot;serve&quot;: {
    &quot;builder&quot;: &quot;@angular-devkit/build-angular:dev-server&quot;,
    &quot;configurations&quot;: {
      &quot;production&quot;: {
        &quot;browserTarget&quot;: &quot;web:build:production&quot;
      },
      &quot;development&quot;: {
        &quot;browserTarget&quot;: &quot;web:build:development&quot;,
        &quot;proxyConfig&quot;: &quot;proxy.config.json&quot;
      }
    },
    &quot;defaultConfiguration&quot;: &quot;development&quot;
  },
  </code></pre>
  <p>and restarted everything:</p>
  <pre><code>ng serve
  </code></pre>
  <p>Now when my angular service try to request <code>/api/dashboard</code>, it still fails.</p>
  <p>On the browser, I get the following error:</p>
  <pre><code> GET http://localhost:4200/api/dashboard/ 504 (Gateway Timeout)
  </code></pre>
  <p>With a second error with the given value:</p>
  <pre><code>{
      &quot;headers&quot;: {
          &quot;normalizedNames&quot;: {},
          &quot;lazyUpdate&quot;: null
      },
      &quot;status&quot;: 504,
      &quot;statusText&quot;: &quot;Gateway Timeout&quot;,
      &quot;url&quot;: &quot;http://localhost:4200/api/dashboard/&quot;,
      &quot;ok&quot;: false,
      &quot;name&quot;: &quot;HttpErrorResponse&quot;,
      &quot;message&quot;: &quot;Http failure response for http://localhost:4200/api/dashboard/: 504 Gateway Timeout&quot;,
      &quot;error&quot;: &quot;Error occurred while trying to proxy: localhost:4200/api/dashboard/&quot;
  }
  </code></pre>
  <p>In my <code>ng serve</code> console, I get this:</p>
  <pre><code>&lt;e&gt; [webpack-dev-server] [HPM] Error occurred while proxying request localhost:4200/api/dashboard/ to https://localhost:7276/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
  </code></pre>
  <p>My understanding is that it returns ANYTHING that match the /api/* to the same URL, not adding again the same initial sub path?</p>
  <p>I can't find how to just change the host, any idea how to do this?</p>