Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
leongrin opened this issue Feb 27, 2020 · 14 comments
Closed

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

leongrin opened this issue Feb 27, 2020 · 14 comments
Labels

Comments

@leongrin
Copy link

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.

@JimLynchCodes
Copy link

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>

@KingDarBoja
Copy link

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 🙈

@JimLynchCodes
Copy link

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

@dherault
Copy link
Owner

dherault commented Mar 2, 2020

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

@dherault dherault added the bug label Mar 2, 2020
@jonathonadams
Copy link
Contributor

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

@dnalborczyk
Copy link
Collaborator

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

@KingDarBoja
Copy link

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

@dl748
Copy link
Contributor

dl748 commented Mar 31, 2020

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

@robsonkades
Copy link

I have the same problem on routes with get

@robsonkades
Copy link

@JimLynchCodes
The same thing happened to me 👁️

@dl748
Copy link
Contributor

dl748 commented Jul 24, 2020

This should be fixed but turning the stage prepending off. There was already a fixed merged for the prepend #946

@lohithn4
Copy link

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

@LBRDan
Copy link

LBRDan commented Sep 3, 2021

This seems to be alive in v8
Same files events/http/HttpServer.js, something betweengenerateHapiPath in createRoutes
Still something is missing for the same reason that makes the path to be '/' == ''

@ajithmohan01
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests