Firebase HTTP function CORS

后端 未结 1 411
温柔的废话
温柔的废话 2021-01-06 22:36

I\'m still having problems with CORS when using Firebase HTTP functions.

Here is my web console error:

Response to preflight request doesn\'t pass ac         


        
1条回答
  •  被撕碎了的回忆
    2021-01-06 23:03

    According to the Firebase documentation, there are a couple of references to CORS configuration:

    Using CORS:

    You can enable the use of CORS by calling it within the function, just like you did in your update to the question:

    // Usage of the `cors` express middleware
    return cors(req, res, () => {
      // TO-DO
    });
    

    Also if you have an already existing Express app, you can then enable CORS by doing:

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

    This is what you had already done on the first step, but there's the difference in the { origin: true } definition, so maybe that is related.

    In any case, as per the documentation it looks like it is indeed fine to add the cors within the request.

    0 讨论(0)
提交回复
热议问题