diff --git a/frontend/src/js/utils.tsx b/frontend/src/js/utils.tsx index 0b25afc..396a577 100644 --- a/frontend/src/js/utils.tsx +++ b/frontend/src/js/utils.tsx @@ -111,7 +111,11 @@ export async function genericapi(method:string,path:string,data:any = undefined, const errorDefault = res.statusText return res.json().then( res => reject(getErrorMessageFromServerResponse(res, errorDefault)) ).catch( _err => reject(errorDefault)) } + // text/plain bodies (the nfproxy filter source) stay strings: a source file that + // happens to be valid JSON must not be parsed into a number/array/object + const isPlainText = (res.headers.get("content-type") ?? "").startsWith("text/plain") res.text().then(t => { + if (isPlainText) return resolve(t) try{ resolve(JSON.parse(t)) }catch(e){ diff --git a/frontend/src/pages/NFProxy/ServiceDetails.tsx b/frontend/src/pages/NFProxy/ServiceDetails.tsx index 2c3afe7..fb5f4f9 100644 --- a/frontend/src/pages/NFProxy/ServiceDetails.tsx +++ b/frontend/src/pages/NFProxy/ServiceDetails.tsx @@ -207,7 +207,7 @@ export default function ServiceDetailsNFProxy() { - {filterCode.data ? <> + {typeof filterCode.data === "string" && filterCode.data ? <> Filter code