Skip to content

Request ID - Can't use aws cloudfront request id #4477

@rtorrente

Description

@rtorrente

What version of Hono are you using?

4.10.12

What runtime/platform is your app running on? (with version if possible)

NodeJS behind cloudfront

What steps can reproduce the bug?

  • Add middleware on your app
router.use(
  requestId({
    // AWS CloudFront adds this header to each request it forwards to the origin
    // https://docs.aws.amazon.com/fr_fr/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html
    headerName: "x-amz-cf-id",
  }),
);
  • Make a request with an header x-amz-cf-id with value wDPR-dHzm9UNK9vGrCTZe6ybr4u8Z7E3yAVZlrHgThoiTpBFq9F3aw==

What is the expected behavior?

  • The provided header (x-amz-cf-id) should be used as request id

What do you see instead?

  • A new request id is generated using generate function

Additional information

We can see here (L49) https://github.com/honojs/hono/blob/main/src/middleware/request-id/request-id.ts#L49 that there is a regexp test [^\w\-] that call generator if request fail.

However, cloudfront request id has a pattern that don't match this regexp like wDPR-dHzm9UNK9vGrCTZe6ybr4u8Z7E3yAVZlrHgThoiTpBFq9F3aw==

What are the reasons of this pattern check ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions