问题描述
我有99%的把握可以为自己的Firebase实时数据库正确设置规则。
React-Redux用于两个调用firebase
的react应用程序,但是问题很令人费解,
1)我创建了一个新的react应用程序并尝试执行axios POST / GET到firebase,但CORS错误不断发生
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 firebaseHowever 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)我使用了旧的react应用并调用了与(1)没有CORS错误相同的API,并且POST请求通过了。
2) I used my old react app and call the same API as (1) no CORS error and the POST request went through.
3)我测试了API是否使用邮递员,POST和GET请求都通过了
3) I test that the API works using postman, both POST and GET request went through
4)我还验证了Firebase在域下的权限设置中是否允许localhost
4) I also verified that localhost was allowed in the permission setting under domain for firebase
任何人都知道哪里出了问题吗?
Anyone got any idea what is wrong?
错误:
employee.js:42 Error: Network Error
at createError (createError.js:17)
at XMLHttpRequest.handleError (xhr.js:80)
推荐答案
@Jered解决方案,通过添加WithCredential解决了该问题
@Jered solution by adding WithCredential solved the issue
这篇关于即使规则设置为true,也可以用Firebase响应CORS问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!