iOS XMLHttpRequest cannot load XXX due to access control checks.
See original GitHub issueGeneral information
- SDK/Library version: 1.22.1
- Environment: Sandbox
- Browser and OS: Safari 13 on iOS 13.1.1
Issue description
When attempting to submit card details using the drop-in UI via Safari 13 on iOS 13.1.1 the UI refreshes and the user can’t proceed forward.
See my code below which was adapted from this official guide https://developers.braintreepayments.com/guides/drop-in/setup-and-integration/javascript/v3:
<form action="{{controllerURL}}" method="post" name="payment_method_form" id="payment_method_form">
<div id="dropin-container"></div>
<button id="submit-button">Pay Now</button>
<script src="https://js.braintreegateway.com/web/dropin/1.22.1/js/dropin.min.js"></script>
<script>
var button = document.querySelector('#submit-button');
braintree.dropin.create({
authorization: {{clientToken}},
container: '#dropin-container'
}, function (createErr, instance) {
button.addEventListener('click', function () {
instance.requestPaymentMethod(function (err, payload) {
if (!err) {
document.getElementById('nonce').value = payload.nonce;
document.payment_method_form.submit();
}
});
});
});
</script>
</form>
This code works absolutely fine on desktop (macOS/windows) and Android (Chrome).
It fails on iOS 13.1.1 using Safari 13 outputting the following errors in the console:
[Error] XMLHttpRequest cannot load https://origin-analytics-sand.sandbox.braintree-api.com/{{marchantID}} due to access control checks. x (hosted-fields-frame.min.html:1:49617) (anonymous function) (hosted-fields-frame.min.html:1:49181)
[Error] XMLHttpRequest cannot load https://api.sandbox.braintreegateway.com/merchants/{{marchantID}}/client_api/v1/payment_methods/credit_cards due to access control checks. x (hosted-fields-frame.min.html:1:49617) (anonymous function) (hosted-fields-frame.min.html:1:48869)
[Error] XMLHttpRequest cannot load https://origin-analytics-sand.sandbox.braintree-api.com/{{marchantID}} due to access control checks. I (dropin.min.js:1:26547) request (dropin.min.js:1:26601) (anonymous function) (dropin.min.js:1:39242) sendEvent (dropin.min.js:1:235035) (anonymous function) (dropin.min.js:1:330055) (anonymous function) promiseReactionJob
[Error] XMLHttpRequest cannot load https://origin-analytics-sand.sandbox.braintree-api.com/{{marchantID}} due to access control checks. I (dropin.min.js:1:26547) (anonymous function) (dropin.min.js:1:26111)
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
XMLHttpRequest with query parameters cannot load due to ...
tried, no change: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'test.
Read more >XMLHTTPRequest cannot load URL_HERE due to access ...
If you look in console it gives a non descript error: XMLHTTPRequest cannot load URL_HERE due to access control checks. Screenshot: stor.fit ...
Read more >XMLHttpRequest cannot load XXX - Error Troubleshooting
XMLHttpRequest cannot load xxxxx. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://xxxxxxx' is therefore ...
Read more >XMLHttpRequest cannot load XXX No 'Access-Control-Allow ...
For any given URL it is possible that the SOP is not needed. A couple of common scenarios where this is the case...
Read more >Fetch Api Cannot Load Due To Access Control Checks
iOS : ios Safari XMLHttpRequest cannot load due to access control checks ... you agree to our use of cookies as described in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
One thing I see is that you’re not preventing the form from submitting (buttons are
submit
type by default). So it’s possible that it’s submitting the form before the nonce is available.Probably want to, at minimum add:
Going to close this for now, because as you said, updating the os fixes the issue. If we get more people reporting it, we can look into it further.
Closing due to inactivity.