Serverless-offline: route not found
In the documentation, it says that serverless-offline will accept requests similar to AWS API Gateway.
I have the following AWS API Gateway endpoint that accepts requests: https://**********.execute-api.us-east-1.amazonaws.com/dev/
However, when I start serverless-offline, the following requests are denied: http://localhost:3000 http://localhost:3000/dev
With a response as following: {"statusCode":404,"error":"Serverless-offline: route not found.","currentRoute":"get - /dev","existingRoutes":[]}
What am I missing?
You have no routes :) "existingRoutes":[]
It might be a plugin issue. Can you tell me your serverless version and serverless-offline version?
Also, do you have at least one handler?
Yes, I have at least one handler that I'm able to call via the "test lambda function" and "API gateway" in AWS. Serverless version: 1.0.0-beta.2 Serverless-offline version: 1.0
@mikestaub @Bilal-S Any thoughts on that?
How do you configure your serverless.yml?
You should put same thing like that :
functions:
load:
handler: loadInteraction/handler.main
events:
- http:
path: /load
method: POST
Thanks, @rroqueCoddera. This solved it.
I hitted the same bug when not defining a service-wide runtime. Serverless issued a warning on the console. In my case I define the runtime in every function (node, python, java).
Adding a runtime at provider solved the issue for me.
I ran into the same issue using JavaScript and serverless.
As soon as I added load:, I started to get following error and serverless offline start will not ever run.
Cannot read property 'split' of undefined
Im getting this error, Using express-node aws. running on server, not on serveless-offline
for route: http://localhost:3000/ {"currentRoute":"get - /","error":"Serverless-offline: route not found.","existingRoutes":["* - /dev","* - /dev/{proxy*}"],"statusCode":404}
for route: http://localhost:3000/dev Cannot GET null
.yml
functions:
app:
handler: index.handler
events:
- http: ANY /
- http: 'ANY {proxy+}'
Im getting this error, Using express-node aws. running on server, not on serveless-offline
for route: http://localhost:3000/ {"currentRoute":"get - /","error":"Serverless-offline: route not found.","existingRoutes":["* - /dev","* - /dev/{proxy*}"],"statusCode":404}
for route: http://localhost:3000/dev Cannot GET null
.yml
functions: app: handler: index.handler events: - http: ANY / - http: 'ANY {proxy+}'
Check out this https://github.com/dougmoscrop/serverless-http/issues/86#issuecomment-627514571
For the "Cannot GET null" issue, try these solutions. Both worked for me.
I can access the root directory at http://localhost:3000/dev//. But http://localhost:3000/dev/ and http://localhost:3000/dev both return Cannot GET null.
See more info in the comment linked above.
Just pointing out that methods above the path behave differently than other way around for all other methods except GET (facepalm) :
- route not found:
- http:
method: ANY
path: /
- http:
method: ANY
path: '{proxy+}'
- working:
- http:
path: /
method: ANY
- http:
path: '{proxy+}'
method: ANY