Using serverless, I am able to execute the hello function defined below. However, when using serverless offline start, serverless-offline is not finding routes.
serverless.yml excerpt
functions:
hello:
handler: handler.hello
events:
- http:
path: hello
method: get
Result of visiting http://localhost:3000/hello
{
statusCode: 404,
error: "Serverless-offline: route not found.",
currentRoute: "get - /hello",
existingRoutes: [ ]
}
handler.js
'use strict';
module.exports.hello = (event, context, callback) => {
const response = {
statusCode: 200,
body: JSON.stringify({
message: 'Go Serverless v1.0! Your function executed successfully!',
input: event,
}),
};
callback(null, response);
// Use this code if you don't use the http event with the LAMBDA-PROXY integration
// callback(null, { message: 'Go Serverless v1.0! Your function executed successfully!', event });
};
Try to change the indentation in serverless.yml to:
functions:
hello:
handler: handler.hello
events:
- http:
path: hello
method: get
That did it. Thank you.
Helped me too, thanks.
Most helpful comment
Try to change the indentation in
serverless.ymlto: