Skip to content

Use event.pathParameters.proxy instead of event.path #182

@hfhchan-plb

Description

@hfhchan-plb

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

3.3.1

Plugin version

No response

Node.js version

18.x

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

13.5

Description

While migrating from serverless-express, I noticed that paths are being processed differently by aws-lambda-fastify. It seems that serverless-express will use event.pathParameters.proxy instead of event.path, which means if on API Gateway I have it configured 'v2/{proxy+}' and I am accessing /v2/token, it will call the express router with the path /token instead of /v2/token.

I wonder if an additional flag can be added to replicate that behaviour?

Steps to Reproduce

I'm using this with NestJS:

      const expressApp = express();
      const adapter = new ExpressAdapter(expressApp);
      await initApp(adapter, appModule);
      const server = configure({
        app: expressApp,
        binarySettings: { contentTypes: ['application/pdf', 'application/x-gzip'] },
      });
      return server;

vs

      const adapter = new FastifyAdapter();
      await initApp(adapter, appModule);
      const server = awsLambdaFastify(adapter.getInstance() as FastifyInstance, {
        binaryMimeTypes: ['application/pdf', 'application/x-gzip'],
        decorateRequest: true,
      });
      return server;

and NestJS with express gives me req.route.path = '/token' while NestJS with fastify gives me req.routerPath = '/v2/token'.

Expected Behavior

Matching serverless-express or providing a flag to toggle that behaviour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions