Angular Universal with AWS Lambda – TypeError

I’m currently struggling to get an Angular Universal app with SSR running with AWS Lambda.

I installed a new Angular app with

ng new my-angular-ssr-app

I added Angular Universal to my Angualr app

ng add @nguniversal/express-engine --clientProject my-angular-ssr-app

I tested that my app works with npm and making a GET-Request (http://localhost:4000/) with Postman

npm run build:ssr && npm run serve:ssr

I zipped the following folders and files with the required dependencies (aws-serverless-express)

- dist
- node_modules
- lambda.js

Uploaded the ZIP to a freshly created AWS Lambda function with a AWS API Gateway trigger

Made a GET-Request to the AWS API Gateway URL and got:

    "message": "Internal server error"

Cloudwatch logs the following for the GET-Request:

2019-10-10T07:17:17.935Z undefined ERROR Uncaught Exception
    "errorType": "TypeError",
    "errorMessage": "Cannot read property 'use' of undefined",
    "stack": [
        "TypeError: Cannot read property 'use' of undefined",
        "    at Object.<anonymous> (/var/task/index.js:25:12)",
        "    at Module._compile (internal/modules/cjs/loader.js:778:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)",
        "    at Module.load (internal/modules/cjs/loader.js:653:32)",
        "    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:585:3)",
        "    at Module.require (internal/modules/cjs/loader.js:692:17)",
        "    at require (internal/modules/cjs/helpers.js:25:18)",
        "    at _tryRequire (/var/runtime/UserFunction.js:75:12)",
        "    at _loadUserApp (/var/runtime/UserFunction.js:95:12)"
2019-10-10T07:17:17.963Z undefined INFO Node Express server listening on http://localhost:4000

My Lambda functions looks like this:

const awsServerlessExpress = require('aws-serverless-express');
const server = require('./dist/server');
const awsServerlessExpressMiddleware = require('aws-serverless-express/middleware');

const binaryMimeTypes = [

const serverProxy = awsServerlessExpress.createServer(, null, binaryMimeTypes);

module.exports.handler = (event, context) => awsServerlessExpress.proxy(serverProxy, event, context);

I clearly did something wrong but I’m not sure what I’m missing. Has someone an idea what I have to change for it to work?

Source: New feed
Source Url Angular Universal with AWS Lambda – TypeError