Skip to content

Latest commit

 

History

History
15 lines (12 loc) · 424 Bytes

bypass-cors-in-cloud-functions.md

File metadata and controls

15 lines (12 loc) · 424 Bytes

Bypass CORS in cloud functions

To bypass CORS errors (but one needs to understand it first rather than falling into the tar pit of immediacy like me) in a cloud function one can do the following:

const cors = require("cors")({ origin: true });

exports.whyAvoidCors = functions.https.onRequest((request, response) => {
  cors(request, response, () => {
    // Function code goes here
    ...
  });
});