feat: update PDF generation endpoint to use direct URL and enable CORS

This commit is contained in:
JOYCEQL
2025-03-05 22:25:53 +08:00
committed by qingchen
parent 02fe8c1e0c
commit 66ece28928
2 changed files with 16 additions and 20 deletions
-9
View File
@@ -10,15 +10,6 @@ const config = {
ignoreBuildErrors: true,
},
output: "standalone",
async rewrites() {
return [
{
source: "/generate-pdf",
destination:
"http://1255612844-0z3iovadu8.ap-chengdu.tencentscf.com/generate-pdf",
},
];
},
};
export default withNextIntl(config);
+16 -11
View File
@@ -111,17 +111,22 @@ const PdfExport = () => {
optimizeImages(clonedElement),
]);
const response = await fetch("/generate-pdf", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
content: clonedElement.outerHTML,
styles,
margin: globalSettings.pagePadding,
}),
});
const response = await fetch(
"http://1255612844-0z3iovadu8.ap-chengdu.tencentscf.com/generate-pdf",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
content: clonedElement.outerHTML,
styles,
margin: globalSettings.pagePadding,
}),
// 允许跨域请求
mode: "cors",
}
);
if (!response.ok) {
throw new Error(`PDF generation failed: ${response.status}`);