Update app.js
Browse files
app.js
CHANGED
|
@@ -2150,11 +2150,13 @@ app.post("/playwright", async (req, res) => {
|
|
| 2150 |
if (!code) return res.status(400).json({ error: "Kode tidak boleh kosong" });
|
| 2151 |
|
| 2152 |
try {
|
| 2153 |
-
const executeCode = new Function(
|
| 2154 |
-
|
| 2155 |
-
|
|
|
|
|
|
|
| 2156 |
|
| 2157 |
-
res.json({
|
| 2158 |
} catch (error) {
|
| 2159 |
res.status(500).json({ error: error.message });
|
| 2160 |
}
|
|
|
|
| 2150 |
if (!code) return res.status(400).json({ error: "Kode tidak boleh kosong" });
|
| 2151 |
|
| 2152 |
try {
|
| 2153 |
+
const executeCode = new Function(`
|
| 2154 |
+
return (async (require, importModule, chromium) => { ${code} })();
|
| 2155 |
+
`).bind(null);
|
| 2156 |
+
|
| 2157 |
+
const result = await executeCode()(require, (mod) => import(mod), chromium);
|
| 2158 |
|
| 2159 |
+
res.json({ result });
|
| 2160 |
} catch (error) {
|
| 2161 |
res.status(500).json({ error: error.message });
|
| 2162 |
}
|