1 year ago
#368041
Prateek Chellani
How can I access an API without running into Allow Access Control Origin issues?
I've noticed that this seems to be a commonly asked question, but none of the responses I've seen have helped so far. I'm trying to access an API (Cuckoo Sandbox, set up on a VM) from my JavaScript+TypeScript application using an Axios call. This is what the code to call the API looks like.
axios({
method: 'get',
url: 'http://192.168.1.220:1337/tasks/view',
headers: {
'Authorization': 'Bearer WoRKpl5',
// 'Allow-Control-Allow-Origin': '*'
},
}).then(resp =>{
console.log("Hi")
}).catch(err => { // then print response status
console.log(err)
});
The response is as shown below:
So far, I've tried editing the api_py file for cuckoo to include headers in the do_post function, modifying the headers in the axios call (commented out), running Chrome browser after disabling web security, trying to disable CORS (unsure if successful) and using a Proxy (CORS-anywhere) hosted on Heroku to add headers, among other things, without much success. Cuckoo Sandbox constantly receives only Options requests. Here is a screenshot of the current headers in the Cuckoo file:
I found it interesting to note that through the regular command line interface and the curl command, the API was working and we could successfully access it. Any further insight on how to successfully hit the API from the application for both GET and POST requests would be helpful.
Thanks
javascript
api
header
cors
cuckoo
0 Answers
Your Answer