Skip to content

Commit

Permalink
Allow redirect to external sites if CORS isn't enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
amitaibu committed Jan 10, 2024
1 parent 0285256 commit f439735
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/IHP/static/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,15 @@ window.submitForm = function (form, possibleClickedButton) {
'Content-Type',
'application/x-www-form-urlencoded'
);
request.send(parameters.join('&'));

try {
request.send(parameters.join('&'));
} catch (e) {
// If the send method throws an exception, redirect to the form action URL.
// This can happen for example if redirecting to an external site, which doesn't have CORS enabled,
// so we can't use Ajax.
window.location.href = url;
}
}

var buttons = form.getElementsByTagName('button');
Expand Down

0 comments on commit f439735

Please sign in to comment.