react firebase functions 发送请求代理失败

新手上路,请多包涵

前端本地启动的, 在调用firebase上的functions的时候报错
`
Error occurred while trying to proxy request /api/screams from localhost:8080 to https://asia-east2-socialape-... (ENOTFOUND)
`

我试过换用其他的在线https://api接口就可以,只有firebase的就出现这个问题,
前端 后端代理的方法都尝试过不生效前端代理
接口

阅读 2.8k
2 个回答
// Listens for new messages added to /messages/:pushId/original and creates an
// uppercase version of the message to /messages/:pushId/uppercase
exports.makeUppercase = functions.database.ref('/messages/{pushId}/original')
    .onWrite(event => {
      // Grab the current value of what was written to the Realtime Database.
      const original = event.data.val();
      console.log('Uppercasing', event.params.pushId, original);
      const uppercase = original.toUpperCase();
      // You must return a Promise when performing asynchronous tasks inside a Functions such as
      // writing to the Firebase Realtime Database.
      // Setting an "uppercase" sibling in the Realtime Database returns a Promise.
      return event.data.ref.parent.child('uppercase').set(uppercase);
    });
新手上路,请多包涵

我在服务端functions 的 index.js中也尝试使用cors了 还不行呃呃呃呃呃

const app = require('express')();
const cors = require('cors')({origin: true});
app.use(cors);

应该是firebase哪里需要怎么配置下吧???

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题