diff --git a/.changeset/full-pigs-post.md b/.changeset/full-pigs-post.md new file mode 100644 index 0000000000..c7c3fe71ba --- /dev/null +++ b/.changeset/full-pigs-post.md @@ -0,0 +1,6 @@ +--- +"@gradio/core": patch +"gradio": patch +--- + +fix:Fix css preload when serving from proxied subpaths diff --git a/js/core/src/css.ts b/js/core/src/css.ts index ca58de5072..8f0452c4f5 100644 --- a/js/core/src/css.ts +++ b/js/core/src/css.ts @@ -14,9 +14,12 @@ if ( export function mount_css(url: string, target: HTMLElement): Promise { const base = new URL(import.meta.url).origin; - const _url = new URL(url, base).href; + var _url = url; + if (window.location.origin !== base) { + // Serving assets over a CDN, generate absolute url + _url = new URL(url, base).href; + } const existing_link = document.querySelector(`link[href='${_url}']`); - if (existing_link) return Promise.resolve(); const link = document.createElement("link");