serverless-components / express

⚡ Take existing Express.js apps and host them easily on cheap, auto-scaling, serverless infrastructure (AWS Lambda and AWS HTTP API).
https://serverless.com/components
Apache License 2.0
375 stars 34 forks source link

Images not served properly #55

Open Pato94 opened 3 years ago

Pato94 commented 3 years ago

I'm experiencing the same issue described here. I'd like to test this solution, but right now I'm using this component, and as far as I know it does not provide any configuration to specify these content-types.

I looked into this file and I noticed the server is not being created with any parameter.

My workaround is going to be not using this component and creating the server myself, but I'd like to use this component in the future. Is it possible to add this content-types as a configuration parameter?

gjgd commented 3 years ago

I'm also experiencing the same issue with serving images through the express component

nemani commented 3 years ago

Hey any updates on this ?! I have been pulling out my hair trying to understand why i cant display images.

nemani commented 3 years ago

Fixed it! you need to set the env variable for the binary_content_types to change the return for isBinary()

component: express
name: express-starter

inputs:
  src:
    src: ./
    hook: npm run build
    dist: build
  timeout: 30
  memory: 1024
  env:
    FONTCONFIG_PATH: '/var/task/fonts'
    BINARY_CONTENT_TYPES: 'image/png, image/jpg'