问题
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