mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-21 01:01:05 +08:00
Initialize the client with the fake host for Lite server (#8935)
* Initialize the client with the fake host for Lite server * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: pngwn <hello@pngwn.io>
This commit is contained in:
parent
15a690fa96
commit
f6b2b97d47
7
.changeset/flat-meals-obey.md
Normal file
7
.changeset/flat-meals-obey.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
"@gradio/app": minor
|
||||
"@gradio/wasm": minor
|
||||
"gradio": minor
|
||||
---
|
||||
|
||||
feat:Initialize the client with the fake host for Lite server
|
@ -10,6 +10,7 @@
|
||||
import ErrorDisplay from "./ErrorDisplay.svelte";
|
||||
import type { ThemeMode } from "../types";
|
||||
import { WorkerProxy, type WorkerProxyOptions } from "@gradio/wasm";
|
||||
import { FAKE_LITE_HOST } from "@gradio/wasm/network";
|
||||
import { Client } from "@gradio/client";
|
||||
import { wasm_proxied_fetch } from "./fetch";
|
||||
import { wasm_proxied_stream_factory } from "./sse";
|
||||
@ -181,7 +182,7 @@
|
||||
<Index
|
||||
space={null}
|
||||
src={null}
|
||||
host={null}
|
||||
host={FAKE_LITE_HOST}
|
||||
{info}
|
||||
{container}
|
||||
{is_embed}
|
||||
|
@ -1,8 +1,12 @@
|
||||
// A special hostname representing the Lite's server.
|
||||
// For example, when the endpoint is a local file (`file:/*`), the host name is set to this value (ref: determine_protocol() in client/js/src/helpers/init_helpers.ts)
|
||||
export const FAKE_LITE_HOST = "lite.local";
|
||||
|
||||
export function is_self_host(url: URL): boolean {
|
||||
return (
|
||||
url.host === window.location.host ||
|
||||
url.host === "localhost:7860" ||
|
||||
url.host === "127.0.0.1:7860" || // Ref: https://github.com/gradio-app/gradio/blob/v3.32.0/js/app/src/Index.svelte#L194
|
||||
url.host === "lite.local" // A special hostname set when the endpoint is a local file (`file:/*`). See `determine_protocol()` in `client/js/src/utils.ts`
|
||||
url.host === FAKE_LITE_HOST
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user