title: how to be able to not return json in express in aws lambda and aws sam when using express.static
body: <p>I am making a serverless website using aws lambda and the sma cli tool from aws (mostly just to test making real requests to the api). I want to serve assets with the express.static function, but have a problem. When i use it I get an error about it not returning json an the error says that it needs to do that to work. I have 2 functions for now: views (to serve the ejs files) and assets (to serve static files like css and frontend js). Here is my template.yml:</p>
  <pre class="lang-yaml prettyprint-override"><code># This is the SAM template that represents the architecture of your serverless application
  # https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-basics.html
  
  # The AWSTemplateFormatVersion identifies the capabilities of the template
  # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/format-version-structure.html
  AWSTemplateFormatVersion: 2010-09-09
  Description: &gt;-
    [Description goes here]
  
  # Transform section specifies one or more macros that AWS CloudFormation uses to process your template
  # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html
  Transform:
  - AWS::Serverless-2016-10-31
  
  # Resources declares the AWS resources that you want to include in the stack
  # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html
  Resources:
    assets:
      Type: AWS::Serverless::Function
      Properties:
        Handler: amplify/backend/function/assets/src/index.handler
        Runtime: nodejs14.x
        MemorySize: 512
        Timeout: 100
        Description: serves the assets
        Events:
          Api:
            Type: Api
            Properties:
              Path: /assets/{folder}/{file}
              Method: GET
    views:
      Type: AWS::Serverless::Function
      Properties:
        Handler: amplify/backend/function/views/src/index.handler
        Runtime: nodejs14.x
        MemorySize: 512
        Timeout: 100
        Description: serves the views
        Events:
          Api:
            Type: Api
            Properties:
              Path: /
              Method: GET
  
  Outputs:
    WebEndpoint:
      Description: &quot;API Gateway endpoint URL for Prod stage&quot;
      Value: !Sub &quot;https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/&quot;
  </code></pre>
  <p>And my code for the assets function:
  index.js:</p>
  <pre class="lang-js prettyprint-override"><code>const awsServerlessExpress = require('aws-serverless-express');
  const app = require('./app');
  
  const server = awsServerlessExpress.createServer(app);
  
  exports.handler = (event, context) =&gt; {
    console.log(`EVENT: ${JSON.stringify(event)}`);
    return awsServerlessExpress.proxy(server, event, context, 'PROMISE').promise;
  };
  </code></pre>
  <p>app.js:</p>
  <pre class="lang-js prettyprint-override"><code>const express = require('express'),
  
      app = express()
  app.use(express.json())
  app.use('/assets', express.static('assets'))
  
  app.listen(3000);
  
  module.exports = app
  </code></pre>
  <p>Is there some config option for the template.yml that I should know or do I have to change my code?</p>