Title: Cloudfront &amp; User Agent
Last modified: May 4, 2020

---

# Cloudfront & User Agent

 *  Resolved [Shane](https://wordpress.org/support/users/shanemarsh28/)
 * (@shanemarsh28)
 * [6 years ago](https://wordpress.org/support/topic/cloudfront-user-agent/)
 * Hello,
 * We currently use your plugin but we recently updated our CDN to Cloudfront. Cloudfront
   caches based on a number of things but the one extra thing it does do is change
   the user-agent to “Amazon Cloudfront” for all requests.
 * This causes the webhook to return a 400 code after line 93 of /includes/class-
   wc-stripe-webhook-handler.php.
 * As a work around I have commented out lines 93-95 within your plugin.
 * Please can we have a check within the plugin that allows for this issue that 
   is specific to those using the Cloudfront CDN?
 * Looking forward to your reply.
    Shane.
    -  This topic was modified 6 years ago by [Shane](https://wordpress.org/support/users/shanemarsh28/).
    -  This topic was modified 6 years ago by [Shane](https://wordpress.org/support/users/shanemarsh28/).

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Joey – a11n](https://wordpress.org/support/users/jricketts4/)
 * (@jricketts4)
 * [6 years ago](https://wordpress.org/support/topic/cloudfront-user-agent/#post-12778746)
 * Hi [@shanemarsh28](https://wordpress.org/support/users/shanemarsh28/) – Have 
   you followed the instructions here to setup the Webhook in Stripe?: [https://docs.woocommerce.com/document/stripe/#section-3](https://docs.woocommerce.com/document/stripe/#section-3)
 * Also, please make sure that you select `Receive all events` when you set up your
   webhook.
 * – Joey
 *  Thread Starter [Shane](https://wordpress.org/support/users/shanemarsh28/)
 * (@shanemarsh28)
 * [6 years ago](https://wordpress.org/support/topic/cloudfront-user-agent/#post-12778923)
 * Hi Joey,
 * Thank for your reply. The issue has nothing to do with Receive all events.
 * This line is the problem (as described above):
 *     ```
       if ( ! empty( $request_headers['USER-AGENT'] ) && ! preg_match( '/Stripe/', $request_headers['USER-AGENT'] ) ) {
           return false;
       }
       ```
   
 * When this line is removed (as per my initial message), the webhook behaves correctly.
 * For confirmation of the issue, see this document from AWS: [https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html)
 * Amazon say:
 * **User-Agent**_: “CloudFront replaces the value of this header field with Amazon
   CloudFront. If you want CloudFront to cache your content based on the device 
   the user is using, see Configuring Caching Based on the Device Type.”_
 * We cannot disable this or work around it by altering the settings within the 
   Cloudfront Distribution therefore we need you to be able to toggle this security
   test on or off from within your plugins settings. Commenting out the three lines
   is sufficient but it’s not a long term fix.
 * I hope this makes more sense.
 * Shane
    -  This reply was modified 6 years ago by [Shane](https://wordpress.org/support/users/shanemarsh28/).
 *  Plugin Support [dougaitken](https://wordpress.org/support/users/dougaitken/)
 * (@dougaitken)
 * Automattic Happiness Engineer
 * [6 years ago](https://wordpress.org/support/topic/cloudfront-user-agent/#post-12826607)
 * Hey [@shanemarsh28](https://wordpress.org/support/users/shanemarsh28/)
 * Can I ask you to open up an Issue on GitHub with the details here, please? I’m
   unsure if we’d create a setting for specifically one CND but the development 
   team can offer their advice around this.
 * Thanks,
 *  Thread Starter [Shane](https://wordpress.org/support/users/shanemarsh28/)
 * (@shanemarsh28)
 * [6 years ago](https://wordpress.org/support/topic/cloudfront-user-agent/#post-12826775)
 * No problem. Issue created here: [https://github.com/woocommerce/woocommerce-gateway-stripe/issues/1195](https://github.com/woocommerce/woocommerce-gateway-stripe/issues/1195)
 *  Plugin Support [dougaitken](https://wordpress.org/support/users/dougaitken/)
 * (@dougaitken)
 * Automattic Happiness Engineer
 * [6 years ago](https://wordpress.org/support/topic/cloudfront-user-agent/#post-12833272)
 * Hi [@shanemarsh28](https://wordpress.org/support/users/shanemarsh28/)
 * I’ll close off this forum thread and pass this to the development team for discussion.
   They will update that GitHub issue with any progress / thoughts.
 * Thanks,

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Cloudfront & User Agent’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-gateway-stripe/assets/icon-256x256.png?rev=3177277)
 * [WooCommerce Stripe Payment Gateway](https://wordpress.org/plugins/woocommerce-gateway-stripe/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-gateway-stripe/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-gateway-stripe/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-gateway-stripe/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-gateway-stripe/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-gateway-stripe/reviews/)

## Tags

 * [CloudFront](https://wordpress.org/support/topic-tag/cloudfront/)

 * 5 replies
 * 3 participants
 * Last reply from: [dougaitken](https://wordpress.org/support/users/dougaitken/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/cloudfront-user-agent/#post-12833272)
 * Status: resolved