I am getting information about blocked access by CORS policy and none of the solutions I looked at seemed to be working.
Access to XMLHttpRequest at 'http://localhost:8000/search' from origin 'http://localhost:8080' has been blocked by CORS policy: No
'Access-Control-Allow-Origin' header is present on the requested resource.
My server is hosted locally on localhost:8000 and frontend is on loacalhost:8080. I want to post text data in Vue with Axios in file: store.js%43:56 :
axios.post('http://localhost:8000/search', {
queryText: 'TEST_TEXT'
}).then(function (response) {
// handle success
console.log(response)
}).catch(function (response) {
// handle error
console.log(response)
})
the backend is written in Django with Rest API. I followed those instructions but the response is still the same. The view responsible for the response is here and settings were set up here
I do not want to:
- Disable web security in Chrome
- Use JSONP
- Use a third party site to re-route my requests
If anyone would like to run the project just install requirements.txt from main folder and follow README from main and frontend folders.