Fix WAF 403 by sending same-origin Origin/Referer to Source API

api_headers() hardcoded Origin/Referer to tconnect.tandemdiabetes.com,
but requests target SOURCE_URL (source.tandemdiabetes.com /
source.eu.tandemdiabetes.com). The WAF enforces same-origin and
returned HTTP 403 ("The request is blocked"). Derive Origin/Referer
from SOURCE_URL so both US and EU regions match.
This commit is contained in:
James Woglom
2026-06-30 22:56:26 +00:00
parent f0f94baf02
commit e5195b2613
+5 -2
View File
@@ -365,8 +365,11 @@ class TandemSourceApi:
raise Exception('No access token provided')
return {
'Authorization': 'Bearer %s' % self.accessToken,
'Origin': 'https://tconnect.tandemdiabetes.com',
'Referer': 'https://tconnect.tandemdiabetes.com/',
# The WAF enforces same-origin: Origin/Referer must match SOURCE_URL
# (source.tandemdiabetes.com / source.eu.tandemdiabetes.com), otherwise
# it returns HTTP 403 ("The request is blocked").
'Origin': self.SOURCE_URL.rstrip('/'),
'Referer': self.SOURCE_URL,
**base_headers()
}