Skip to content

Commit

Permalink
fix: Handle ec2 instances public url seperately when extracting TLDs
Browse files Browse the repository at this point in the history
  • Loading branch information
KShivendu committed Sep 18, 2023
1 parent 34887f8 commit 00a5ae0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions supertokens_python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,16 @@ def get_top_level_domain_for_same_site_resolution(url: str) -> str:

if hostname.startswith("localhost") or is_an_ip_address(hostname):
return "localhost"

parsed_url: Any = extract(hostname, include_psl_private_domains=True)
if parsed_url.domain == "": # type: ignore
if hostname.endswith(".amazonaws.com"):
# Example: url http://ec2-xx-yyy-zzz-0.compute-1.amazonaws.com
# return ec2-xx-yyy-zzz-0.compute-1.amazonaws.com
# If user deploys the website on the same ec2 instance as the API
# this use SameSite=lax, otherwise SameSite=none
return hostname

raise Exception(
"Please make sure that the apiDomain and websiteDomain have correct values"
)
Expand Down

0 comments on commit 00a5ae0

Please sign in to comment.