wip fix proxy
This commit is contained in:
parent
527601f03a
commit
da3f21cad2
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue