futurestudio / hapi-rate-limitor

A hapi plugin for rate limiting. Simple and easy.
MIT License
43 stars 8 forks source link

Hiding / Removing the "X-Rate-Limit-Limit" and other headers #201

Closed eliyahu2 closed 2 years ago

eliyahu2 commented 2 years ago

Is there a way to hide those in the response or are those required? what are they used for? there is no documentation for why they are set besides a simple note... image

Plus, trying to remove them in "onReponse" by setting them to null doesn't work, how can it be done?

Thanks

marcuspoehls commented 2 years ago

@eliyahu2 Hey, the X-Rate-Limit-* headers can be used to check your rate limit. For example, if you don’t have any -Remaining requests, you can calculate the number of seconds using -Reset until you can send another request that won’t be rate-limited.

Does that answer your question?

eliyahu2 commented 2 years ago

Hi! Thank you for your quick response, actually We're looking to know:

  1. Can the X-Rate-Limit-* flags be removed? is it crucial for the rate limiter to work?

  2. In the case that it can be removed, how can it be done? We've tried settings the response.header('X-Rate-Limit-Limit', null) during the "OnPreResponse" stage of hapi but it can still be shown in the browser.

Thank you very much for your assistance

marcuspoehls commented 2 years ago

@eliyahu2 At this point, there’s no option to disable the rate-limiting headers when rate-limiting applies to a route. If I remember correctly, this plugin won’t set these response headers if a route is not rate-limited.

My approach to remove the headers if you don’t want them:

eliyahu2 commented 2 years ago

@marcuspoehls Thanks That's very helpful!

marcuspoehls commented 2 years ago

Nice 😊🤜🤛

marcuspoehls commented 2 years ago

@eliyahu2 I saw you reopened this issue. Do you need help?