title: Angular Proxy Partial URL Rewrite Not Occuring as Expected
body: <p>I want to run an Angular 7 app on a dev server and access xml data from a test database (<a href="https://demo.aligni.com/api/v2/oid3vLgynoy_Yl1gZkrgkLEq3J/part/000222?find_by=partnumber" rel="nofollow noreferrer">https://demo.aligni.com/api/v2/oid3vLgynoy_Yl1gZkrgkLEq3J/part/000222?find_by=partnumber</a>)</p>
  
  <p>Angular complained righteously about CORS, and SO answers and webpack documentation led me to the same conclusion - create a proxy and rewrite the url to get around my CORS issue. </p>
  
  <p>However, Webpack's pathRewrite is not working as expected to yield the result I want. </p>
  
  <p>I tried setting up the proxy.conf.json file as follows. </p>
  
  <pre><code>{
      "/api/*": {
          "target": "https://demo.aligni.com/api/v2/",
          "secure": false,
          "logLevel":"debug",
          "pathRewrite": {"^api/": ""}
          }
  }
  </code></pre>
  
  <p>The Relevant portion from my app.component.ts</p>
  
  <pre><code>this.http.get(
      '/api/oid3vLgynoy_Yl1gZkrgkLEq3J/part/728', 
      {
      headers: httpHeaders,
      responseType: 'text'})
      .subscribe((data)=&gt; console.log(data), (err)=&gt;console.log(err));
  </code></pre>
  
  <p>}</p>
  
  <p>My actual results from the proxy.conf.json logging:</p>
  
  <pre><code>[HPM] GET /api/oid3vLgynoy_Yl1gZkrgkLEq3J/part/728 -&gt; https://demo.aligni.com/api/v2/
  </code></pre>
  
  <p>Based on the webpack documentation "the configuration below will rewrite the HTTP requests to remove the part /api at the beginning of the URL" [Rewriting URLS of proxy request: <a href="https://github.com/webpack/docs/wiki/webpack-dev-server]" rel="nofollow noreferrer">https://github.com/webpack/docs/wiki/webpack-dev-server]</a>...
  My expected results :</p>
  
  <pre><code>GET /api/oid3vLgynoy_Yl1gZkrgkLEq3J/part/728 -&gt; https://demo.aligni.com/api/v2/oid3vLgynoy_Yl1gZkrgkLEq3J/part/728
  </code></pre>
  
  <p>To get the expected results, I would only have to remove the part /api at the beginning of the URL specified in the Angular call (exactly what is stated by the web-pack docs), and add it to my target.</p>
  
  <p>The pathRewrite is removing the entire URL, not just the 'api/' part of it as I would expect.  </p>
  
  <p>Of course Angular gives me a 404 as you will get if you visit <a href="https://demo.aligni.com/api/v2/" rel="nofollow noreferrer">https://demo.aligni.com/api/v2/</a></p>
  
  <p>I could not find an example for this use case with pathRewrite, where I actually need part of the URL being sent in.  After a couple hours of searching I've seen some xml path rewrite rules, but I couldn't find a good learning resource. 
   I'd prefer to solve this with pathRewrite if possible. Thanks very much in advance, this is all a bit new to me. </p>