mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-21 01:01:05 +08:00
Fix css preload when serving from proxied subpaths (#9822)
* Fix assets when serving from subpath * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: pngwn <hello@pngwn.io>
This commit is contained in:
parent
4d520a8a7b
commit
2e2cdbfb60
6
.changeset/full-pigs-post.md
Normal file
6
.changeset/full-pigs-post.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@gradio/core": patch
|
||||||
|
"gradio": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix:Fix css preload when serving from proxied subpaths
|
@ -14,9 +14,12 @@ if (
|
|||||||
|
|
||||||
export function mount_css(url: string, target: HTMLElement): Promise<void> {
|
export function mount_css(url: string, target: HTMLElement): Promise<void> {
|
||||||
const base = new URL(import.meta.url).origin;
|
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}']`);
|
const existing_link = document.querySelector(`link[href='${_url}']`);
|
||||||
|
|
||||||
if (existing_link) return Promise.resolve();
|
if (existing_link) return Promise.resolve();
|
||||||
|
|
||||||
const link = document.createElement("link");
|
const link = document.createElement("link");
|
||||||
|
Loading…
Reference in New Issue
Block a user