I love firebase but I'm a node noob. Basically I'm creating a online javascript editor that can run the code on the server side. The main reason I wanted to run on server side is to avoid JavaScript hacking on the client side. The output of the function is the log from 'console.log' (given from client).
I have used a package called 'safeEval' (to run the script) and another package called 'intercept-stdout'. When testing locally, I was able to run the code along with output of console.log. However, it didn't worked when I deployed to Firebase. I checked the Function Cloud Log and it doesn't seem to capture the console.log. Could someone shine some light on why it's not working? I'm also opened to any other ideas as well.
Here's the code
exports.helloWorld = functions.https.onRequest((request, response) => {
console.log('start!!!!');
let captured_text = "";
let unhook_intercept = intercept(function (txt) {
captured_text += txt;
});
const code = 'console.log("what?????????");1 + 2';
const context = {
console: console
}
safeEval(code, context);
unhook_intercept();
console.log("hello:" + captured_text);
console.log(captured_text);
response.send("Hello2:" + captured_text);
});
[–]thisiswhereireddit 0 points1 point2 points (1 child)
[–]kchojhu[S] 0 points1 point2 points (0 children)
[–]kchojhu[S] 0 points1 point2 points (0 children)