title: How to get rid of "500 Internal Server Error" using ui5-middleware-simpleproxy
body: <p>I built an SAPUI5 app using <a href="https://sap.github.io/ui5-tooling/" rel="nofollow noreferrer">UI5 Tooling</a> and now I'm having trouble connecting it to an OData service.<br />
  <a href="https://i.stack.imgur.com/TCfYJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TCfYJ.png" alt="500 Internal Server Error" /></a></p>
  <hr />
  <p>Since the real url to the OData Service is not public, let's just call it:</p>
  <pre><code>http://app99.sap.domain.com/sap/opu/odata/sap/Z_DOMAIN_SRV/
  </code></pre>
  <p>and opening it in my browser, adding <code>$metadata?sap-language=DE</code> at the end, works - I get the XML metadata document.</p>
  <hr />
  <p>These are the files I tried to change to connect to the OData service:</p>
  <blockquote>
  <ul>
  <li>webapp
  <ul>
  <li>manifest.json</li>
  </ul>
  </li>
  <li>package.json</li>
  <li>ui5.yaml</li>
  </ul>
  </blockquote>
  <p>Adding a <code>&quot;dataSources&quot;</code>-object and a <code>&quot;models&quot;</code>-object in <code>manifest.json</code></p>
  <pre><code>{
    &quot;sap.app&quot;: {
      ...
      &quot;dataSources&quot;: {
        &quot;oDataService&quot;: {
          &quot;uri&quot;: &quot;/sap/opu/odata/sap/Z_DOMAIN_SRV/&quot;,
          &quot;type&quot;: &quot;OData&quot;
        }
      }
    },
    &quot;sap.ui5&quot;: {
      ...
      &quot;models&quot;: {
        ...
        &quot;&quot;: {
          &quot;dataSource&quot;: &quot;oDataService&quot;,
          &quot;preload&quot;: true,
          &quot;settings&quot;: {
            &quot;useBatch&quot;: false
          }
        }
      },
      ...
    }
  }
  </code></pre>
  <p>I also tried changing the <code>&quot;uri&quot;</code> value to the real link, <code>http://app99.sap.domain.com/sap/opu/odata/sap/Z_DOMAIN_SRV/</code>, but then I expectedly get a <code>Cross-Origin</code> error:<br />
  <a href="https://i.stack.imgur.com/pJDmt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pJDmt.png" alt="Cross-Origin Error" /></a></p>
  <p>So I tried setting up a proxy by adding this to my <code>package.json</code>:</p>
  <pre><code>{
    ...
    &quot;devDependencies&quot;: {
      &quot;ui5-middleware-simpleproxy&quot;: &quot;^0.5.1&quot;
    },
    &quot;ui5&quot;: {
      &quot;dependencies&quot;: [
        &quot;ui5-middleware-simpleproxy&quot;
      ]
    },
    ...
  }
  </code></pre>
  <p>and adding this to my <code>ui5.yaml</code> file:</p>
  <pre><code>...
  server:
    customMiddleware:
      - name: ui5-middleware-simpleproxy
        mountPath: /sap/opu/odata/sap/Z_DOMAIN_SRV
        afterMiddleware: compression
        configuration:
          baseUri: &quot;http://app99.sap.domain.com/sap/opu/odata/sap/Z_DOMAIN_SRV/&quot;
  </code></pre>
  <p>hoping that now<br />
  <code>http://localhost:8080/sap/opu/odata/sap/Z_DOMAIN_SRV/$metadata?sap-language=DE</code><br />
  would turn into<br />
  <code>http://app99.sap.domain.com/sap/opu/odata/sap/Z_DOMAIN_SRV/$metadata?sap-language=DE</code><br />
  and it would work, but that isn't the case - I just get the error from the screenshot on top.</p>
  <p>Any idea what I am missing?<br />
  I really want to make it work with this <a href="https://www.npmjs.com/package/ui5-middleware-simpleproxy" rel="nofollow noreferrer">ui5-middleware-simpleproxy</a>, because I don't want to start up two servers manually (the UI5 Tooling one and another one for the proxy). Currently I just need to do <code>ui5 serve</code> and everything works out of the box.</p>