jdavidbakr / mail-tracker

Package for Laravel to inject tracking code into outgoing emails.
MIT License
574 stars 129 forks source link

Fixes SNS Endpoint Header check issue for Serverless Environments (Laravel Vapor) #244

Closed UtkuDalmaz closed 8 months ago

UtkuDalmaz commented 8 months ago

In serverless environments, such as Laravel Vapor, the direct access to $_SERVER global variable for retrieving request headers, such as HTTP_X_AMZ_SNS_MESSAGE_TYPE, is unreliable. This becomes a problem when handling Amazon Simple Notification Service (SNS) messages, as it's essential to validate the type of SNS message being processed. The Laravel way of accessing request headers through the Request object should be used instead to ensure compatibility across different environments, including serverless.

This pull request addresses this issue by replacing direct $_SERVER access with the Laravel Request object for fetching the x-amz-sns-message-type header. It ensures that the application remains environment-agnostic and functions correctly in both server-based and serverless deployments.