• Resolved parhaggstrom

    (@parhaggstrom)


    Hi. Thanks for a great plugin. I would like a way to filter/remove predefined headers that are sent on cached responses.

    As it looks right now I had to edit the plugin inside the get_api_cache() function where it calls rest_send_cors_headers function that sends the predefined headers.

    Background why is that I use AngularJS $http service with WP REST and somehow it creates duplicate headers entries instead of overwriting them. The ones I had was better configured and as I can see it there is only a way to add custom headers, not a way to remove the predefined ones

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Richard Korthuis

    (@rockfire)

    Hi @parhaggstrom

    Thank you for using our plugin!

    The function rest_send_cors_headers you are refering to, is actually a slightly altered version of the same function in the WordPress core. We intend to remove it in a future version and we will then be using the core function. Therefore we will not be able to add any hooks into it, since these hooks will not work anymore once we start using the core function.
    But to understand your question better: You are refering to the Access-Control-Allow-* headers and the Vary: Origin header? If so, don’t you have the exact same problem when you are not using our plugin? These headers are also added when you don’t use our plugin. Please let us know, so we can investigate if there is any possibility for us to help you with your issue.

    Thread Starter parhaggstrom

    (@parhaggstrom)

    Thanks. Yes I wanted to send Access-Control-Allow-Origin header but it added both mine and your default one resulting in sending duplicates.

    Somehow I later got it working on my live env with your function activated but could’nt get it to work on my local env without commenting it out. So I now believe it to be something with my setup even if beeing able to modify them would be great.

    I dont know if the WP Core function does have a filter. But if you are gonna drop your function then I see no need for this filter anymore. I will look into the core function

    Thanks again

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘A way to filter/remove predefined headers on cached responses’ is closed to new replies.