File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import BrowserOnly from '@docusaurus/BrowserOnly';
22import type { WrapperProps } from '@docusaurus/types' ;
33import type LayoutType from '@theme/Layout' ;
44import Layout from '@theme-original/Layout' ;
5- import { type ReactNode } from 'react' ;
5+ import { type ReactNode , useState , useEffect } from 'react' ;
66
77import GoogleOneTapInitializer from './GoogleOneTapInitializer' ;
88import { useGoogleOneTapConfig } from './hooks' ;
@@ -11,11 +11,24 @@ type Props = WrapperProps<typeof LayoutType>;
1111
1212export default function LayoutWrapper ( props : Props ) : ReactNode {
1313 const { config } = useGoogleOneTapConfig ( ) ;
14+ const [ isInIframe , setIsInIframe ] = useState ( false ) ;
15+
16+ useEffect ( ( ) => {
17+ // Check if the page is embedded in an iframe
18+ try {
19+ setIsInIframe ( window . self !== window . top ) ;
20+ } catch {
21+ // If accessing window.top throws an error, we're in a cross-origin iframe
22+ setIsInIframe ( true ) ;
23+ }
24+ } , [ ] ) ;
1425
1526 return (
1627 < >
1728 < Layout { ...props } />
18- { config ?. oneTap ?. isEnabled && < BrowserOnly > { ( ) => < GoogleOneTapInitializer /> } </ BrowserOnly > }
29+ { config ?. oneTap ?. isEnabled && ! isInIframe && (
30+ < BrowserOnly > { ( ) => < GoogleOneTapInitializer /> } </ BrowserOnly >
31+ ) }
1932 </ >
2033 ) ;
2134}
Original file line number Diff line number Diff line change 11/*
2- Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://akasha.logto.io https://accounts.google.com; connect-src 'self' https://akasha.logto.io https://accounts.google.com https://auth.logto.dev https://*.logto.dev https://auth.logto.io https://*.logto.io https://api.inkeep.com; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://accounts.google.com https://fonts.googleapis.com; font-src 'self' https://cdn.jsdelivr.net https://fonts.gstatic.com; frame-src https://accounts.google.com; img-src 'self' data: https:; object-src 'none'; base-uri 'self'; form-action 'self' https://*.logto.dev https://*.logto.io https://cloud.logto.dev https://cloud.logto.io; frame-ancestors 'none'
2+ Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://akasha.logto.io https://accounts.google.com; connect-src 'self' https://akasha.logto.io https://accounts.google.com https://auth.logto.dev https://*.logto.dev https://auth.logto.io https://*.logto.io https://api.inkeep.com; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://accounts.google.com https://fonts.googleapis.com; font-src 'self' https://cdn.jsdelivr.net https://fonts.gstatic.com; frame-src https://accounts.google.com; img-src 'self' data: https:; object-src 'none'; base-uri 'self'; form-action 'self' https://*.logto.dev https://*.logto.io https://cloud.logto.dev https://cloud.logto.io
You can’t perform that action at this time.
0 commit comments