Skip to content

Commit

Permalink
fix sample on Safari (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
bentsku authored Dec 23, 2023
1 parent 650f4bc commit 87f4cc1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ awslocal lambda list-function-url-configs --function-name presign | jq -r '.Func
echo "Fetching function URL for 'list' Lambda..."
awslocal lambda list-function-url-configs --function-name list | jq -r '.FunctionUrlConfigs[0].FunctionUrl'

echo "Now open the Web app under https://webapp.s3.localhost.localstack.cloud/index.html and paste the function URLs above (make sure to use https:// as protocol)"
echo "Now open the Web app under https://webapp.s3-website.localhost.localstack.cloud and paste the function URLs above (make sure to use https:// as protocol)"
8 changes: 6 additions & 2 deletions website/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@
event.returnValue = false;

event.preventDefault();

let action = $(this).find("button[type=submit]:focus").attr('name');
if (action === undefined) {
// the jquery find with the focus does not work on Safari, maybe because the focus is not instantly given
// fallback to manually retrieving the submitter from the original event
action = event.originalEvent.submitter.getAttribute('name')
}

if (action == "load") {
let baseUrl = `${document.location.protocol}//${document.location.host}`;
if (baseUrl.indexOf("file://") >= 0) {
baseUrl = `http://localhost:4566`;
}
baseUrl = baseUrl.replace("://webapp.s3.", "://");
baseUrl = baseUrl.replace("://webapp.s3.", "://").replace("://webapp.s3-website.", "://");
const headers = {authorization: "AWS4-HMAC-SHA256 Credential=test/20231004/us-east-1/lambda/aws4_request, ..."};
const loadUrl = async (funcName, resultElement) => {
const url = `${baseUrl}/2021-10-31/functions/${funcName}/urls`;
Expand Down

0 comments on commit 87f4cc1

Please sign in to comment.