Last active
April 8, 2021 07:21
-
-
Save hewigovens/c9bcd5c7e1b00532292af8120f45ed4d to your computer and use it in GitHub Desktop.
Test CORS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var testEndpointCORS = (url) => { | |
var method = "POST"; | |
var xhr = new XMLHttpRequest(); | |
var json = { | |
jsonrpc: "2.0", | |
method: "eth_getBlockByHash", | |
params: [ | |
"0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35", | |
true, | |
], | |
id: 1, | |
}; | |
xhr.onload = console.log; | |
xhr.onerror = console.log; | |
xhr.open(method, url, true); | |
xhr.setRequestHeader("Content-Type", "application/json"); | |
xhr.send(JSON.stringify(json)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to test:
testEndpointCORS(<your_eth_endpoint>)