React CORS issue with firebase even though rule is set to true

守給你的承諾、 提交于 2020-05-15 21:35:25

问题


I am 99% sure that i set the rules correctly for my firebase realtime database. React-Redux is used for by both react app that call the firebase However the problem is quite puzzling, 1) I created a new react app and try to do an axios POST/GET to the firebase but CORS error keep happening

2) I used my old react app and call the same API as (1) no CORS error and the POST request went through.

3) I test that the API works using postman, both POST and GET request went through

4) I also verified that localhost was allowed in the permission setting under domain for firebase

Anyone got any idea what is wrong?

error:

Access to XMLHttpRequest at 'https://...firebaseio./Employee.json' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

employee.js:42 Error: Network Error
    at createError (createError.js:17)
    at XMLHttpRequest.handleError (xhr.js:80)

回答1:


@Jered solution by adding WithCredential solved the issue



来源:https://stackoverflow.com/questions/57827465/react-cors-issue-with-firebase-even-though-rule-is-set-to-true

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!