Following the instructions in the Coinbase Cloud documentation, I tried running this code on the client side using JavaScript:
const options = {
method: 'GET',
headers: {
Accept: 'application/json',
'cb-access-key': 'Apikey',
'cb-access-passphrase': 'Mypassphrase',
'cb-access-sign': cb_access_sign,
'cb-access-timestamp': cb_access_timestamp
}
};
fetch('https://api.exchange.coinbase.com/coinbase-accounts', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
I encountered the same issue when attempting to do it with axios.
An error was displayed in the console:
"Access to fetch at 'https://api.exchange.coinbase.com/coinbase-accounts' from origin 'http://localhost:3000' has been blocked by CORS policy:
Request header field cb-access-passphrase is not allowed by Access-Control-Allow-Headers in preflight response."
Could someone please advise on what I might be doing incorrectly?