@@ -3,7 +3,7 @@ import { OAuthResult } from '@huggingface/hub'
33import { Config , ConfigProvider , Page , getHttpSource } from 'hyperparam'
44import { useEffect , useMemo , useState } from 'react'
55import { fetchOAuth , getLocalOAuth } from '../../lib/auth.js'
6- import { getHuggingFaceSource , syncParentQueryString } from '../../lib/huggingfaceSource.js'
6+ import { getHuggingFaceSource } from '../../lib/huggingfaceSource.js'
77import Home from '../Home/Home.js'
88
99function getRequestInit ( accessToken : string | undefined ) : RequestInit | undefined {
@@ -78,10 +78,17 @@ export default function App() {
7878 return < div > Could not load a data source. You have to pass a valid source in the url, eg: < a href = { defaultUrl } > { defaultUrl } </ a > .</ div >
7979 }
8080
81- // Send a message to the parent window to synchronize the query string
82- // Note that the iframe has no access to the parent window's location, so
83- // it might already by in sync, we just don't know.
84- syncParentQueryString ( window . location . search )
81+ /* Send a message to the parent window to synchronize the query string
82+ *
83+ * Hugging Face Space impose some restrictions to the static apps that are hosted on their platform,
84+ * with respect to the URLs. Only hash and query strings can be changed, and doing so requires
85+ * some custom code:
86+ * https://huggingface.co/docs/hub/spaces-handle-url-parameters
87+ *
88+ * Note that the iframe has no access to the parent window's location, so
89+ * it might already by in sync, we just don't know.
90+ */
91+ window . parent . postMessage ( { queryString : window . location . search } , 'https://huggingface.co' )
8592
8693 return < ConfigProvider value = { config } >
8794 < Page source = { source } navigation = { { row, col } } />
0 commit comments