Answer the question
In order to leave comments, you need to log in
How to send an axios request to Firebase from local hosting, is CORS interfering now?
Good afternoon! Now I'm taking one of the courses on React and ran into one problem. The problem is that, due to CORS rules, I cannot access another domain from the local host.
There are many methods on the net, but many I do not know how to use in my case. I'm using the default application launch that is used in react: react-scripts start. So I don't know where to put the node.js related code.
I use this construct
try {
const response = await axios.post('https://quiz-react-3618f.firebaseio.com/quizes', this.state.quiz)
console.log(response)
} catch(e) {
console.log(e);
}
Access to XMLHttpRequest at 'https://quiz-react-3618f.firebaseio.com/quiz' from origin 'https://quiz-react-3618f.web.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question