SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site, support.twilio.com, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to help.twilio.com, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

Troubleshooting Analytics.js Custom Proxy CORS ERR_FAILED Errors

Issue

Customers using a self-managed custom proxy for Segment Analytics.js may experience a drop-off in events and see a net::ERR_FAILED or missing Access-Control-Allow-Origin CORS error in their browser developer console. This occurs because calls to the custom proxy endpoint fail when the preflight OPTIONS request is rejected by the proxy's CORS policy.

 

Product

Segment Destinations

 

Environment

Segment Console

 

Cause

A recent update to the Analytics.js library unified and hardened HTTP response handling. This update introduced two new HTTP headers to the requests: Authorization and X-Retry-Count. If a self-managed custom proxy is not configured to recognize and allow these new headers during the preflight CORS OPTIONS request, the proxy rejects the request. This results in the browser blocking the request due to the missing Access-Control-Allow-Origin response header.

 

Resolution

To resolve this issue, you must update the CORS policy configuration on your self-managed proxy or CDN (such as AWS CloudFront).

  1. Access your proxy or CDN configuration settings.
  2. Locate the CORS policy or Allowed Headers configuration for the distribution routing traffic to Segment.
  3. Add Authorization to the list of allowed headers.
  4. Add X-Retry-Count to the list of allowed headers.
  5. Save your changes and deploy the updated proxy configuration.

 

Additional Information 

Because custom proxies are managed entirely on your end, you are responsible for maintaining the infrastructure and configurations. If your workspace is on the Business Tier, Segment recommends utilizing the fully-managed Custom Domain feature instead of a custom proxy. With Custom Domain, Segment manages the infrastructure, SSL certificates, and any necessary header updates seamlessly, which prevents the need for manual configuration updates when the SDK changes. 

Have more questions? Submit a request
Powered by Zendesk