title: Defining custom Express endpoint for SAP CAP app
body: <p>I am trying to create a standard SAP CAP (Cloud Platform Application Model) in SAP Business Application Studio and also extending it with additional Express endpoints besides the ones served by CDS services. I have the following project structure:</p>
  <p><a href="https://i.stack.imgur.com/f437O.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f437O.jpg" alt="Project structure" /></a></p>
  <p>Content of package.json:</p>
  <pre><code>{
  &quot;name&quot;: &quot;&lt;app-name&gt;&quot;,
  &quot;version&quot;: &quot;1.0.0&quot;,
  &quot;description&quot;: &quot;A simple CAP project.&quot;,
  &quot;repository&quot;: &quot;&lt;Add your repository here&gt;&quot;,
  &quot;license&quot;: &quot;UNLICENSED&quot;,
  &quot;private&quot;: true,
  &quot;dependencies&quot;: {
      &quot;@sap/cds&quot;: &quot;^3&quot;,
      &quot;@sap/cds-dk&quot;: &quot;^1.8.5&quot;,
      &quot;@sap/hana-client&quot;: &quot;^2.4.177&quot;,
      &quot;express&quot;: &quot;^4&quot;,
      &quot;multer&quot;: &quot;^1.4.2&quot;
  },
  &quot;scripts&quot;: {
      &quot;start&quot;: &quot;npx cds run&quot;
  },
  &quot;cds&quot;: {
      &quot;hana&quot;: {
          &quot;deploy-format&quot;: &quot;hdbtable&quot;
      },
      &quot;requires&quot;: {
          &quot;db&quot;: {
              &quot;kind&quot;: &quot;sql&quot;
          }
      }
  },
  &quot;devDependencies&quot;: {
      &quot;sqlite3&quot;: &quot;^4.2.0&quot;
  }}
  </code></pre>
  <p>Server.js:</p>
  <pre><code>module.exports = async() =&gt; {
  const express = require('express')
  const cds = require('@sap/cds')
  
  const app = express()
  const port = process.env.port || 4004
  
  app.use('/', express.static('app/'))
  app.get('/', (req, res) =&gt; res.redirect(&quot;/app/index.html&quot;))
  
  cds.connect(&quot;db&quot;)
  .serve(&quot;all&quot;)
  .in(app)
  
  return app.listen(port, () =&gt; console.log(`Example app listening at http://localhost:${port}`))}
  </code></pre>
  <p>When I run <em>cds watch</em> command the application properly starts, however when I open the Fiori Elements application the following error message appears:</p>
  <p><a href="https://i.stack.imgur.com/MpCmN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MpCmN.jpg" alt="Error message in Fiori App" /></a></p>
  <p>If I remove the server.js file from the srv folder, the application works perfectly. What could cause the error message? Is there any additional configuration required?</p>