Fix: 修改脚本
This commit is contained in:
parent
d652f16801
commit
c5c196ad98
12
index.js
12
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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue