cors icon indicating copy to clipboard operation
cors copied to clipboard

feat: Add callback for configuring Vary header

Open gl-jkeys opened this issue 11 months ago • 4 comments

Fixes #317

This PR adds a callback (shouldSetVaryHeader) to the options which is used to determine when and how to configure the Vary header.

To preserve backward compatibility with all existing cors usages, this callback returns true by default.

If this PR is accepted, I will add documentation to the README on how to use this PR's functionality.

gl-jkeys avatar Mar 23 '24 00:03 gl-jkeys

I enabled the CI to run in this PR :+1:

UlisesGascon avatar Apr 01 '24 11:04 UlisesGascon

Hey @gl-jkeys 👋, first of all, thank you for being an awesome contributor.

If this PR is accepted, I will add documentation to the README on how to use this PR's functionality.

It makes more sense if that README change is also included in this PR. Could you please take care of that?

(Note to self: I was unable to run the tests due to my own PC issue, I will check the tests again sometime later soon).

IamLizu avatar Sep 15 '24 09:09 IamLizu

Hey @IamLizu, I made the changes you requested; I also modified the PR to unconditionally set the Vary: Origin header for OPTIONS requests. (It seems unlikely, in hindsight since this PR was opened, that OPTIONS requests would be cached without respect to Origin.) I also simplified the tests to match the updated implementation.

gl-jkeys avatar Sep 16 '24 00:09 gl-jkeys