更新时间:2023-01-18 12:40:51
我遇到了类似的问题.在本地运行函数(即firebase serve
)时,我能够成功使用Books API.但是,当我将功能和应用程序部署到托管时,我得到了一个神秘的403: Forbidden
错误.
I was facing a similar issue. I was able to sucessfully use the Books API when I was running my functions locally (ie. firebase serve
). But when I deployed the functions and the app to hosting, I was getting a mysterious 403: Forbidden
error.
我尝试了几件事,所以不确定是否有帮助,所以我只列出所有内容:
I tried several things so I'm not sure which helped so I'll just list everything:
npm install --save firebase-functions@latest
node-fetch
切换为使用axios
来调用API https://www.googleapis.com/books/v1/volumes?country=US&q=insubject:${randomWord}&key=${functions.config().books.api.key}
Application restrictions
npm install --save firebase-functions@latest
node-fetch
to using axios
for calling the APIhttps://www.googleapis.com/books/v1/volumes?country=US&q=insubject:${randomWord}&key=${functions.config().books.api.key}
Application restrictions
in the google cloud console希望这对外面的人有帮助,因为我已经花了好几个小时了!
Hope this helps somebody out there because I was wrestling with it for hours!