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

Created on 27 Feb 2020  ·  12Comments  ·  Source: dherault/serverless-offline

I have the latest version of serverless-offline installed. My Angular 9 Universal app is running smoothly locally. But I can't run it with serverless-offline. I am getting this error:

{
currentRoute: "get - /",
error: "Serverless-offline: route not found.",
existingRoutes: [
"* - /production",
"* - /production/{proxy*}"
],
statusCode: 404
}

Before I updated to the latest version of serverless-offline, at least loaded the favicon. Now, not even the favicon is loading.

Here is my serverless.yml code:

# generated by @ng-toolkit/serverless
service: brmed

plugins:
  - serverless-apigw-binary
  - serverless-offline

provider:
  name: aws
  runtime: nodejs12.x
  memorySize: 192
  timeout: 50
  stage: production
  region: us-east-2

package:
  exclude:
   - src/**
   - node_modules/**
   - firebug-lite/**
   - e2e/**
   - coverage/**
   - '!node_modules/aws-serverless-express/**'
   - '!node_modules/binary-case/**'
   - '!node_modules/type-is/**'
   - '!node_modules/media-typer/**'
   - '!node_modules/mime-types/**'
   - '!node_modules/mime-db/**'

custom:
  apigwBinary:
    types:
      - '*/*'
  serverless-offline:
    httpPort: 8181

functions:
  api:
    handler: lambda.universal
    events:
      - http: ANY {proxy+}
      - http: ANY /

Does anybody here know how to solve this issue or help me with tips of where I should be looking at? I am really lost. Without more specific errors, it's very difficult to debug.

bug

Most helpful comment

I had this problem with anything 6+, this was due to the fact that it now defaults to appending the staging name to the url path. To revert to the old way, you need to add --noPrependStageInUrl to the cli or in the serverless file custom: serverless-offline noPrependStageInUrl: true to revert to previous setting. I'm testing it his out but @dherault the functionality is not reflecting what is actually happening in AWS.

i put a console.log(event.path) in AWS vs Serverless Offline

https://<awsdomain>/dev/this/that  AWS shows  '/this/that'
https://<localhost>/dev/this/that  with prepend on show '/this/that'
https://<localhost>/this/that  with prepend off show 'this/that'

Which can break existing software as now it needs to know if prepend is on or off

All 12 comments

My project also stopped working.

Trying to hit any route now gives me this error:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>Error</title>
</head>

<body>
    <pre>Cannot GET /jokes</pre>
</body>

</html>

Wait a minute, I have seen this before... ng-toolkit package right there!

So this is related to #905 and hence, to my comment.

I am trying to achieve the same thing for upcoming ng-toolkit version 🙈

Still no idea what happened, but after I restarted my computer it worked again. 🤷‍♂️

@dnalborczyk this happened after a new version was released, can you pinpoint which one?

@dherault Did you see my PR #905 in relation to this issue?

Specifically

Prior to 6.0.0-alpha.54, the event.path property would reflect the current request path. eg /graphql
6.0.0-alpha.56 appended the stage to the path, e.g. event.path: /dev/graphql
6.0.0-alpha.61 removed the stage but the path that is defined in the serverless.yml is used for for every request, e.g. event.path: /{any+}

@dherault I'm currently slammed at work. it'll probably take a while for me to have a look.

The new version got released today, I will try and see how it goes as @jadams88 PR got merged too! 🚀

I had this problem with anything 6+, this was due to the fact that it now defaults to appending the staging name to the url path. To revert to the old way, you need to add --noPrependStageInUrl to the cli or in the serverless file custom: serverless-offline noPrependStageInUrl: true to revert to previous setting. I'm testing it his out but @dherault the functionality is not reflecting what is actually happening in AWS.

i put a console.log(event.path) in AWS vs Serverless Offline

https://<awsdomain>/dev/this/that  AWS shows  '/this/that'
https://<localhost>/dev/this/that  with prepend on show '/this/that'
https://<localhost>/this/that  with prepend off show 'this/that'

Which can break existing software as now it needs to know if prepend is on or off

I have the same problem on routes with get

@JimLynchCodes
The same thing happened to me :eye:

This should be fixed but turning the stage prepending off. There was already a fixed merged for the prepend https://github.com/dherault/serverless-offline/pull/946

I had this problem with anything 6+, this was due to the fact that it now defaults to appending the staging name to the url path. To revert to the old way, you need to add --noPrependStageInUrl to the cli or in the serverless file custom: serverless-offline noPrependStageInUrl: true to revert to previous setting. I'm testing it his out but @dherault the functionality is not reflecting what is actually happening in AWS.

i put a console.log(event.path) in AWS vs Serverless Offline

https://<awsdomain>/dev/this/that  AWS shows  '/this/that'
https://<localhost>/dev/this/that  with prepend on show '/this/that'
https://<localhost>/this/that  with prepend off show 'this/that'

Which can break existing software as now it needs to know if prepend is on or off

Thanks, Happy Merry Christmas,
this worked out for me...

custom:
  serverless-offline:
    noPrependStageInUrl: true

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yareyaredesuyo picture yareyaredesuyo  ·  4Comments

stonebraker picture stonebraker  ·  3Comments

adambiggs picture adambiggs  ·  4Comments

ozbillwang picture ozbillwang  ·  4Comments

Dong9769 picture Dong9769  ·  4Comments