title: ASP.NET Core Api-Gateway middleware
body: <p>I am new to API gateways and have a question of understanding.
  I try too put a series of (micro)services behind an endpoint.</p>
  
  <p>For this purpose, I have set up an ASP.NET Core Application and added the package <a href="https://github.com/ThreeMammals/Ocelot" rel="noreferrer">ThreeMammals Ocelot</a>.
  With the help of documentation I have configured the Up- and Downstreams.
  So far, so good.</p>
  
  <p><a href="https://i.stack.imgur.com/d8UZm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/d8UZm.png" alt="sketch"></a></p>
  
  <p>The client makes a request to <a href="http://mygateway:4242/s1/" rel="noreferrer">http://mygateway:4242/s1/</a>{api} and, for example, get a JSON or XML response from Service1, as expected.</p>
  
  <p>Same behavior for <a href="http://mygateway:4242/s2/" rel="noreferrer">http://mygateway:4242/s2/</a>{api} with also the expected result!</p>
  
  <p>My understanding problem is with Service3.
  When I send a request to <a href="http://mygateway/s3/" rel="noreferrer">http://mygateway/s3/</a>, I get the index.html as response.</p>
  
  <p>The index.html itself requires the CSS-File 'xyz.css' via link-tag and forces the client to load the file.</p>
  
  <pre><code>&lt;head&gt;
    &lt;link rel="stylesheet" type="text/css" href="xyz.css"&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>The request URL the client send to "mygateway" in this case is <a href="http://mygateway:4242/xyz.css" rel="noreferrer">http://mygateway:4242/xyz.css</a> and not 
  <a href="http://mygateway:4242/" rel="noreferrer">http://mygateway:4242/</a><strong>s3</strong>/xyz.css and so the respone is a 404 not found, since the "mygateway" knows nothing about a "xyz.css"</p>
  
  <p>How can I fix this routing(?) issue? </p>
  
  <p>Is it possible to solve this problem with ocelot middleware? Or do I need something else for the service (Service3) with the SinglePageApplication (SPA)?</p>
  
  <p>Maybe is it simply not possible or wrong to place the SPA behind the gateway?
  I hope you can give me some tips to get access to a SPA or MVC website behind a gateway.</p>
  
  <p>Thanks iBot</p>
  
  <hr>
  
  <p><strong>UPATE:</strong>
  Enclosed the code of index.html. I think that's straight forward.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&gt;
      &lt;title&gt;Title&lt;/title&gt;
      &lt;base href="/" /&gt;
  
      &lt;link rel="stylesheet" type="text/css" href="dist/xyz.css"&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="appContainer"&gt;&lt;/div&gt;
      &lt;script src="dist/xyz.js" asp-append-version="true"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>