Skip to content

Commit

Permalink
enable cors for fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
ibastawisi committed Jan 9, 2025
1 parent cc3e9f8 commit 35f1f8c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 13 additions & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
5 changes: 3 additions & 2 deletions src/editor/nodes/SketchNode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(/<!-- payload-start -->\s*(.+?)\s*<!-- payload-end -->/, "").replaceAll('//dist/','/');
const src = `data:image/svg+xml,${encodeURIComponent(decoded)}`;
return (
<ImageComponent
width={self.__width}
height={self.__height}
src={self.__src}
src={src}
altText={self.__altText}
nodeKey={self.__key}
showCaption={self.__showCaption}
Expand Down

0 comments on commit 35f1f8c

Please sign in to comment.