From c5c196ad98fa2c2bd40d3369ae87be4d6b486673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=87=E8=B6=A3=E4=BF=9D=E7=BD=97?= Date: Mon, 8 Sep 2025 10:54:46 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E4=BF=AE=E6=94=B9=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 2fa8880..a75f03d 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,9 @@ const express = require("express"); const playwright = require("playwright"); const app = express(); -const port = 3000; +const port = 3004; +// const proxyUrl = "https://smartart-dev.felo.ai"; +const proxyUrl = "http://localhost:5173/"; // 用户提供的,用于初始化图形的 JS 对象 const graphicInitPayload = { @@ -100,7 +102,7 @@ async function renderGraphic() { try { // 3. 导航到目标网页 console.log("Node.js: Navigating to page..."); - await page.goto("http://localhost:5173/", { + await page.goto(proxyUrl, { waitUntil: "domcontentloaded", }); console.log("Node.js: Page navigation complete."); @@ -141,7 +143,9 @@ app.get("/render", async (req, res) => { const data = await renderGraphic(); // 返回从页面获取到的 value 对象 res.setHeader("Content-Type", "application/json"); - res.json(data.value); + console.log(data); + + res.json(data); } catch (error) { console.error("Failed to render graphic:", error); res @@ -160,7 +164,7 @@ const server = app.listen(port, async () => { `Playwright-based graphic rendering service listening at http://localhost:${port}` ); console.log( - "Please make sure your frontend dev server is running on http://localhost:5173" + `Please make sure your frontend dev server is running on ${proxyUrl}` ); console.log(`To render a graphic, access: http://localhost:${port}/render`); } catch (error) {