Skip to content

Commit

Permalink
fix: use full URL in resource
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanpm committed Nov 18, 2021
1 parent d6a5627 commit 43b896e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions exodus_lambda/functions/origin_request.py
Expand Up @@ -147,11 +147,14 @@ def handler(self, event, context):
request = event["Records"][0]["cf"]["request"]

if request["uri"].startswith("/_/"):
return self.meta_handler(request)
return self.meta_handler(event)

return self.content_handler(request)

def meta_handler(self, request):
def meta_handler(self, event):
cf = event["Records"][0]["cf"]
request = cf["request"]

uri = request["uri"]

if not uri.startswith("/_/cookie/"):
Expand All @@ -163,14 +166,16 @@ def meta_handler(self, request):

expire = timedelta(minutes=30)

hostname = cf["config"]["distributionDomainName"]

cookies_content = signer.cookies_for_policy(
append=f"; Secure; Path=/content/; Max-Age={int(expire.total_seconds())}",
resource="/content/*",
resource=f"https://{hostname}/content/*",
date_less_than=datetime.utcnow() + expire,
)
cookies_origin = signer.cookies_for_policy(
append=f"; Secure; Path=/origin/; Max-Age={int(expire.total_seconds())}",
resource="/origin/*",
resource=f"https://{hostname}/origin/*",
date_less_than=datetime.utcnow() + expire,
)

Expand Down

0 comments on commit 43b896e

Please sign in to comment.