From 35f1f8ccf244688985e31230f1e9dfb77d8edb1b Mon Sep 17 00:00:00 2001 From: Ibrahim El-bastawisi Date: Thu, 9 Jan 2025 17:10:44 +0200 Subject: [PATCH] enable cors for fonts --- next.config.ts | 13 +++++++++++++ src/editor/nodes/SketchNode/index.tsx | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/next.config.ts b/next.config.ts index 1019139e..b57021e1 100644 --- a/next.config.ts +++ b/next.config.ts @@ -40,6 +40,19 @@ const nextConfig: NextConfig = { }); return config }, + async headers() { + return [ + { + source: "/(.*)\.woff2", + headers: [ + { key: "Access-Control-Allow-Credentials", value: "true" }, + { key: "Access-Control-Allow-Origin", value: "*" }, + { key: "Access-Control-Allow-Methods", value: "GET,OPTIONS,PATCH,DELETE,POST,PUT" }, + { key: "Access-Control-Allow-Headers", value: "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" }, + ] + } + ] + } }; export default withBundleAnalyzer(withBundleAnalyzerConfig)(withPWA(withPWAConfig)(nextConfig)); \ No newline at end of file diff --git a/src/editor/nodes/SketchNode/index.tsx b/src/editor/nodes/SketchNode/index.tsx index 022b5bac..eb941262 100644 --- a/src/editor/nodes/SketchNode/index.tsx +++ b/src/editor/nodes/SketchNode/index.tsx @@ -161,12 +161,13 @@ export class SketchNode extends ImageNode { const self = this.getLatest(); const html = self.__caption.getEditorState().read(() => $generateHtmlFromNodes(self.__caption)); const children = htmr(html); - + const decoded = decodeURIComponent(self.__src.split(',')[1]).replace(/\s*(.+?)\s*/, "").replaceAll('//dist/','/'); + const src = `data:image/svg+xml,${encodeURIComponent(decoded)}`; return (