From c140f98441d2155ea4fb544ebff266d9afcd2d6f Mon Sep 17 00:00:00 2001 From: Rizky Date: Wed, 7 Feb 2024 17:59:46 +0700 Subject: [PATCH] wip fix --- app/web/src/base/load/proxy.ts | 12 +++++- app/web/src/nova/vi/load/load-snapshot.tsx | 45 ++++++++++------------ 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/app/web/src/base/load/proxy.ts b/app/web/src/base/load/proxy.ts index 11f85704..ecee6e7d 100644 --- a/app/web/src/base/load/proxy.ts +++ b/app/web/src/base/load/proxy.ts @@ -69,10 +69,18 @@ export const fetchViaProxy = async ( (Array.isArray(data) && data[0] instanceof File) ) { if (data instanceof File) { - const res = await fetch(url, { body: data, headers: _headers }); + const res = await fetch(url, { + body: data, + method: "POST", + headers: _headers, + }); return await res.text(); } else { - const res = await fetch(url, { body: data[0], headers: _headers }); + const res = await fetch(url, { + body: data[0], + method: "POST", + headers: _headers, + }); return await res.text(); } } else { diff --git a/app/web/src/nova/vi/load/load-snapshot.tsx b/app/web/src/nova/vi/load/load-snapshot.tsx index 0f7fb796..6c630923 100644 --- a/app/web/src/nova/vi/load/load-snapshot.tsx +++ b/app/web/src/nova/vi/load/load-snapshot.tsx @@ -14,38 +14,35 @@ export const viLoadSnapshot = async (p: PG) => { try { const apiURL = new URL(api_url); if (api_url && apiURL.hostname) { - try { - await loadApiProxyDef(api_url, true); + await loadApiProxyDef(api_url, true); - const api = w.prasiApi[api_url]; - if (api && api.apiTypes && api.prismaTypes) { - const zip = JSON.stringify({ - api: api.apiTypes, - prisma: api.prismaTypes, - }); - const hash = hashCode(zip); - const res = await p.sync?.code.action({ - type: "check-typings", + const api = w.prasiApi[api_url]; + if (api && api.apiTypes && api.prismaTypes) { + const zip = JSON.stringify({ + api: api.apiTypes, + prisma: api.prismaTypes, + }); + const hash = hashCode(zip); + const res = await p.sync?.code.action({ + type: "check-typings", + site_id: p.site.id, + hash, + }); + if (res?.type === "check-typings" && !res.hash) { + const body = Buffer.from(compress(encoder.encode(zip))); + p.sync?.code.action({ + type: "push-typings", site_id: p.site.id, + body, hash, }); - if (res?.type === "check-typings" && !res.hash) { - const body = Buffer.from(compress(encoder.encode(zip))); - p.sync?.code.action({ - type: "push-typings", - site_id: p.site.id, - body, - hash, - }); - } } - } catch (e) { - console.warn("Failed to load API:", api_url); } } - } catch (e) {} + } catch (e) { + console.warn("Failed to load API:", api_url); + } - console.log(p.site.code); if (p.site.code.snapshot) { for (const [name, build] of Object.entries(p.site.code.snapshot)) { const doc = new Y.Doc();