wip fix proxy

This commit is contained in:
Rizky 2024-01-22 11:38:36 +07:00
parent 527601f03a
commit da3f21cad2
3 changed files with 10 additions and 9 deletions

View File

@ -29,7 +29,7 @@ export const loadApiProxyDef = async (url: string, with_types: boolean) => {
apiEntry: (await apiEntry.json()).srv,
};
if (with_types) {
if (with_types) {
const apiTypes = await fetch(base + "/_prasi/api-types");
w.prasiApi[url].apiTypes = await apiTypes.text();
w.prasiApi[url].prismaTypes = {

View File

@ -13,7 +13,7 @@ export const apiProxy = (api_url: string) => {
try {
const base = new URL(api_url);
const base_url = `${base.protocol}//${base.host}`;
let base_url = `${base.protocol}//${base.host}`;
if (!w.prasiApi[base_url]) {
if (!apiProxyLoaded[base_url]) {
apiProxyLoaded[base_url] = loadApiProxyDef(base_url, true);

View File

@ -32,9 +32,8 @@ export const _ = {
if (mode === "dev") {
src = `\
(() => {
const baseurl = new URL("https://prasi.avolut.com/");
baseurl.pathname = '';
const url = baseurl.toString();
//[[REPLACE]]
const url = \`\${baseurl.protocol}//\${baseurl.host}\`;
const w = window;
if (!w.prasiApi) {
w.prasiApi = {};
@ -52,9 +51,8 @@ export const _ = {
} else {
src = `\
(() => {
const baseurl = new URL("https://prasi.avolut.com/");
baseurl.pathname = '';
const url = baseurl.toString();
//[[REPLACE]]
const url = \`\${baseurl.protocol}//\${baseurl.host}\`;
const w = window;
if (!w.prasiApi) {
w.prasiApi = {};
@ -65,7 +63,10 @@ export const _ = {
})();`;
}
cache[mode] = src;
cache[mode] = src.replace(
"//[[REPLACE]]",
`const baseurl = new URL(${url})`
);
}
res.send(cache[mode]);