Skip to content

Commit

Permalink
fix: proxy fonts
Browse files Browse the repository at this point in the history
Signed-off-by: ayushnirwal <[email protected]>
  • Loading branch information
ayushnirwal committed Jan 30, 2025
1 parent 0e53824 commit d724f22
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/next/src/components/font.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import getConfig from 'next/config';
import React from 'react';

/**
Expand All @@ -11,11 +12,19 @@ import React from 'react';
*/
export default function Fonts( props: { renderedFontFaces: string } ) {
const { renderedFontFaces } = props;

const { homeUrl, useCorsProxy, corsProxyPrefix } = getConfig();

// Proxy font URLs to prevent CORS issue
const fontStyle = useCorsProxy
? renderedFontFaces.replaceAll( homeUrl, corsProxyPrefix )
: renderedFontFaces;

return (
<style
id="wp-fonts-local"
dangerouslySetInnerHTML={ {
__html: renderedFontFaces
__html: fontStyle
?.replace( "<style id='wp-fonts-local'>", '' )
?.replace( '</style>\n', '' ),
} }
Expand Down

0 comments on commit d724f22

Please sign in to comment.