-
-
Notifications
You must be signed in to change notification settings - Fork 796
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
Handler event path and resource don't match pattern returned from lambda #1029
Comments
I am using version 6.3.2 and still facing this issue. Getting the actual resource path in lambda |
same here |
This issue has not been resolved yet. serverless.yml service: myservice
plugins:
- serverless-offline
provider:
name: aws
runtime: nodejs12.x
region: ap-northeast-1
stage: dev
functions:
handler:
handler: index.handler
events:
# simple path
- http:
method: get
path: /route
# path parameter
- http:
method: get
path: /{id}/param
# greedy path parameter
- http:
method: get
path: /greedy/{proxy+} index.js 'use strict'
const { stringify } = JSON
exports.handler = (event, context, callback) => {
const { path, resource, requestContext } = event
const {
path: requestContextPath,
resourcePath: requestContextResourcePath,
} = requestContext
const response = {
path,
resource,
requestContext: {
path: requestContextPath,
resourcePath: requestContextResourcePath,
},
}
callback(null, {
statusCode: 200,
body: stringify(response, null, 2),
})
} AWSsimple path $ curl https://xxxxxxxxxx.execute-api.ap-northeast-1.amazonaws.com/dev/route
{
"path": "/route",
"resource": "/route",
"requestContext": {
"path": "/dev/route",
"resourcePath": "/route"
}
} with path parameter $ curl https://xxxxxxxxxx.execute-api.ap-northeast-1.amazonaws.com/dev/1/param
{
"path": "/1/param",
"resource": "/{id}/param",
"requestContext": {
"path": "/dev/1/param",
"resourcePath": "/{id}/param"
}
} with greedy path parameter $ curl https://xxxxxxxxxx.execute-api.ap-northeast-1.amazonaws.com/dev/greedy/abc
{
"path": "/greedy/abc",
"resource": "/greedy/{proxy+}",
"requestContext": {
"path": "/dev/greedy/abc",
"resourcePath": "/greedy/{proxy+}"
}
} with custom domain and base path mapping (base path is $ curl https://mycustomdomain/base/route
{
"path": "/base/route",
"resource": "/route",
"requestContext": {
"path": "/base/route",
"resourcePath": "/route"
}
} serverless-offlinesimple path
$ curl localhost:3000/dev/route
{
"path": "/route",
"resource": "/route",
"requestContext": {
"path": "/route",
"resourcePath": "/dev/route"
}
} with path parameter
$ curl localhost:3000/dev/1/param
{
"path": "/1/param",
"resource": "/1/param",
"requestContext": {
"path": "/1/param",
"resourcePath": "/dev/{id}/param"
}
} with greedy path parameter
$ sls offline
$ curl localhost:3000/dev/greedy/abc
{
"path": "/greedy/abc",
"resource": "/greedy/abc",
"requestContext": {
"path": "/greedy/abc",
"resourcePath": "/dev/greedy/{proxy*}"
}
} with
$ curl localhost:3000/base/route
{
"path": "/base/route",
"resource": "/base/route",
"requestContext": {
"path": "/base/route",
"resourcePath": "/base/route"
}
} |
I'm not sure why this one is closed? Resource path is still completely incorrect: |
Bug Report - Handler event path and resource don't match pattern returned from lambda
The serverless-offline handler
event
object is returning the prefixed/<stage>
on theevent.resource
, when it should not.The serverless-offline handler
event
object is not returning the prefixed/<stage>
on theevent.path
, when it should.There are also similar issues in the
event.requestContext.path
andevent.requestContext.resourcePath
.Current Behavior
Currently, the
event.path
andevent.resource
are returned as follows:In serverless-offline :
In lambda - with default auto generated domain:
In lambda - with custom domain and path map:
Sample Code
Expected behavior/code
I'd expect the
event.path
,event.resource
,event.requestContext.path
andrequestContext.resourcePath
to match at least one of the results from lambda.Environment
serverless
version: 1.72.0serverless-offline
version: 6.4.0Additional context/Screenshots
Possibly related to #917
The text was updated successfully, but these errors were encountered: