I have a test database in MongoDB Atlas. Using the MongoDB Realm service, I've been able to set up a GraphQL endpoint for the database.
I can run queries internally with their sandbox (GraphiQL).
After configuring the API key auth provider...
...I was able to run queries externally from Postman, calling https://realm.mongodb.com/api/client/v2.0/app/<MY_APP_ID>/graphql.
However, trying to make the same call using axios...
await axios({
method: 'POST',
url:
'https://realm.mongodb.com/api/client/v2.0/app/<MY_APP_ID>/graphql',
headers: {
apiKey: '<MY_API_KEY>',
'Content-Type': 'application/json',
},
data: {
query: `
{
item {
_id
name
description
}
}
`
}
})
...gives a CORS error.
Is there something I need to configure in Realm or a header that I'm missing to allow external access to the GraphQL endpoint from the browser?




