TypeError: cors_proxy.emit is not a function [Firebase Functions]
peter-palmer opened this issue · 1 comments
peter-palmer commented
I have deployed in Firebase Functions, calling the function by HTTP, but I'm getting this error:
index.js
const functions = require("firebase-functions");
const cors_proxy = require("cors-anywhere");
const options = {
originWhitelist: [], // Allow all origins
requireHeader: ["origin", "x-requested-with"],
};
cors_proxy.createServer(options);
exports.corsProxyRequest = functions.https.onRequest((req, res) => {
req.url = req.url.replace("/corsProxyRequest/https:/", "/https://");
cors_proxy.emit("request", req, res);
});
firebase.json
{
"rewrites": [
{
"source": "**",
"function": "corsProxyRequest"
}
]
}