Serverless-offline: Serverless-offline: route not found.

Created on 12 Oct 2017  路  3Comments  路  Source: dherault/serverless-offline

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 });
};

Most helpful comment

Try to change the indentation in serverless.yml to:

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: hello
          method: get

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aldofunes picture aldofunes  路  3Comments

ghost picture ghost  路  4Comments

davidroman0O picture davidroman0O  路  4Comments

mattmeye picture mattmeye  路  4Comments

Dong9769 picture Dong9769  路  4Comments