I make this API request , using axios in ReactJS
axios.post(`${API_URL}/valida_proximo`, { id: images.map(image => image.id) }, getAxiosConfig()) // this.setState({ images, loadingAtribuiImagens: false}) } It works really well in Google Chrome, but on Firefox I receive an error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:5000/valida_proximo. (Reason: CORS request did not succeed).[Learn More]
What can I do?
This is my API
@blueprint.route('', methods=['POST', ]) @jwt_required() def index(): if request.json: id_usuarioImagem = request.json.get('id') imagens_selecionadas = UsuarioImagem.query.filter(UsuarioImagem.id.in_(id_usuarioImagem)).all() if imagens_selecionadas: for imagem_selecionada in imagens_selecionadas: imagem_selecionada.batido=True db.session.commit() return 'ok', 200 return 'error', 400
fetch(), I know I need to add'credentials': 'same-origin'to the args to make CORS work. But, I can't find an equivalent option for axios. There are also many, numerous other things that could go wrong with CORS, but, this is where I would start.