[英]internal server error with when deploying express with serverless
im facing a problem that i really couldn't resolve for days, I am trying to deploy my express app to AWS using serverless, but when I try to access the endpoint I receive this error我遇到了几天都无法解决的问题,我正在尝试使用无服务器将我的 Express 应用程序部署到 AWS,但是当我尝试访问端点时,我收到此错误
{"message": "Internal server error"} {“消息”:“内部服务器错误”}
i really can't figure out the problem also viewed the other similar questions but nothing works我真的无法弄清楚问题也查看了其他类似的问题,但没有任何效果
here is my serverless.yml这是我的 serverless.yml
service: my-express-application
provider:
name: aws
runtime: nodejs14.x
stage: dev
region: us-east-1
functions:
app:
handler: app.handler
events:
- http: ANY /
- http: 'ANY /{proxy+}'
and this is my app.js这是我的 app.js
const keys = require("./config/keys");
const activitiesRoutes = require("./routes/activity");
const app = express();
const bodyParser = require("body-parser");
const router = express.Router();
const AWS = require("aws-sdk");
AWS.config.update({
region: "us-east-1",
});
var docClient = new AWS.DynamoDB.DocumentClient();
// set view engine
app.set("view engine", "ejs");
// set up session cookies
app.use(
cookieSession({
maxAge: 24 * 60 * 60 * 1000,
keys: [keys.session.cookieKey],
})
);
// initialize passport
app.use(passport.initialize());
app.use(passport.session());
// connect to mongodb
mongoose.connect(keys.mongodb.dbURI, () => {
console.log("connected to mongodb");
});
// set up routes
/
app.listen(3000, () => {
console.log("app now listening for requests on port 3000");
});
module.exports = serverless(app);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.