serverless-offline icon indicating copy to clipboard operation
serverless-offline copied to clipboard

Serverless-offline: route not found

Open ashachar opened this issue 10 years ago • 11 comments

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?

ashachar avatar Aug 27 '16 21:08 ashachar

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?

dherault avatar Aug 29 '16 07:08 dherault

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

ashachar avatar Aug 29 '16 19:08 ashachar

@mikestaub @Bilal-S Any thoughts on that?

dherault avatar Aug 30 '16 07:08 dherault

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

rroqueCoddera avatar Aug 30 '16 19:08 rroqueCoddera

Thanks, @rroqueCoddera. This solved it.

ashachar avatar Aug 30 '16 22:08 ashachar

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.

mancvso avatar Oct 26 '17 20:10 mancvso

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

rajivkanaujia avatar Nov 29 '17 19:11 rajivkanaujia

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+}'

codegrabs avatar Apr 07 '20 14:04 codegrabs

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

EngrEric avatar May 12 '20 18:05 EngrEric

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.

shah-a avatar May 17 '21 11:05 shah-a

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

zub0r avatar Apr 06 '23 08:04 zub0r