mirror of
https://github.com/logos-storage/logos-storage-marketplace-ui.git
synced 2026-01-05 23:13:08 +00:00
Add VITE_CODEX_SELF_HOSTED to define the default url from the self hosted protocol and domain
This commit is contained in:
parent
d2be5a6ac2
commit
e762e69810
@ -1,8 +1,18 @@
|
|||||||
import { Codex } from "@codex-storage/sdk-js";
|
import { Codex } from "@codex-storage/sdk-js";
|
||||||
import { WebStorage } from "../utils/web-storage";
|
import { WebStorage } from "../utils/web-storage";
|
||||||
|
|
||||||
let client: Codex = new Codex(import.meta.env.VITE_CODEX_API_URL);
|
let defaultUrl = import.meta.env.VITE_CODEX_API_URL;
|
||||||
let url: string = import.meta.env.VITE_CODEX_API_URL;
|
|
||||||
|
if (import.meta.env.VITE_CODEX_SELF_HOSTED === "1") {
|
||||||
|
defaultUrl = window.location.href;
|
||||||
|
|
||||||
|
if (defaultUrl.endsWith("/")) {
|
||||||
|
defaultUrl = defaultUrl.slice(0, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let client: Codex = new Codex(defaultUrl);
|
||||||
|
let url: string = defaultUrl;
|
||||||
|
|
||||||
export const CodexSdk = {
|
export const CodexSdk = {
|
||||||
url() {
|
url() {
|
||||||
@ -11,7 +21,7 @@ export const CodexSdk = {
|
|||||||
|
|
||||||
load() {
|
load() {
|
||||||
return WebStorage.get<string>("codex-node-url").then((u) => {
|
return WebStorage.get<string>("codex-node-url").then((u) => {
|
||||||
url = u || import.meta.env.VITE_CODEX_API_URL;
|
url = u || defaultUrl;
|
||||||
client = new Codex(url);
|
client = new Codex(url);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -24,18 +34,18 @@ export const CodexSdk = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
debug() {
|
debug() {
|
||||||
return client.debug
|
return client.debug;
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return client.data
|
return client.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
node() {
|
node() {
|
||||||
return client.node
|
return client.node;
|
||||||
},
|
},
|
||||||
|
|
||||||
marketplace() {
|
marketplace() {
|
||||||
return client.marketplace
|
return client.marketplace;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
1
src/vite-env.d.ts
vendored
1
src/vite-env.d.ts
vendored
@ -5,6 +5,7 @@ interface ImportMetaEnv {
|
|||||||
VITE_CODEX_API_URL: string;
|
VITE_CODEX_API_URL: string;
|
||||||
VITE_GEO_IP_URL: string;
|
VITE_GEO_IP_URL: string;
|
||||||
VITE_DISCORD_LINK: string;
|
VITE_DISCORD_LINK: string;
|
||||||
|
VITE_CODEX_SELF_HOSTED: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ImportMeta {
|
interface ImportMeta {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user