I’m trying to deploy an express app with ejs view-engine as an AWS Lambda function using serverless I’m really new to serverless framework and need some guidelines.
PROBLEM: The deployment is successfull but I get {"message": "Internal server error"}
from AWS endpoint
Here’s my Express server.js
const serverless = require('serverless-http');
const Dotenv = require('dotenv').config();
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static('public'));
app.set('view engine', 'ejs');
app.get('/', function (req, res) {
res.render('index',{data: {name: user}, error: null});
}
module.exports.handler = serverless(app);
And serverless.yml
org: dk013
app: wforecast
service: wforecast
provider:
name: aws
runtime: nodejs12.x
stage: dev
region: us-east-1
functions:
app:
handler: app.handler
events:
- http: ANY /
- http: 'ANY {proxy+}'
plugins:
- serverless-offline
Any guidelines on what is wrong with my code/config or how to do it teh right way is appreciated