Skip to content

Commit

Permalink
fix: cannot access http csharp validator
Browse files Browse the repository at this point in the history
- use url to condition is http or https, if is
https then add the httpsagent
  • Loading branch information
Chinlinlee committed Mar 9, 2022
1 parent 97df6f1 commit 2593f98
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions models/FHIR/fhir-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ async function refreshResourceResolver() {
rejectUnauthorized: false
});
let APIUrl = new nodeUrl.URL("/api/refreshresourceresolver" , VALIDATION_API_URL).href;
let fetchRes = await fetch(APIUrl, {
method: "POST",
agent: httpsAgent
});
let fetchConfig = {
method: "POST"
};
if (APIUrl.startsWith("https://")) fetchConfig.agent = httpsAgent;
let fetchRes = await fetch(APIUrl, fetchConfig);
logger.info(`[Info: Refresh C# Validator Resource Resolver] [Content: ${JSON.stringify(await fetchRes.json())}]`);
} catch(e) {
throw e;
Expand All @@ -159,14 +160,15 @@ async function validate(profile, resourceContent) {
profile: profile,
resourceJson: JSON.stringify(resourceContent)
};
let fetchRes = await fetch(APIUrl, {
let fetchConfig = {
method: "POST",
body: JSON.stringify(body),
agent: httpsAgent,
headers: {
'content-type': 'application/json'
}
});
};
if (APIUrl.startsWith("https://")) fetchConfig.agent = httpsAgent;
let fetchRes = await fetch(APIUrl, fetchConfig);
let fetchResJson = await fetchRes.json();
logger.info(`[Info: Call Validation function from C# successfully] [URL: ${APIUrl}]`);
return fetchResJson;
Expand Down

0 comments on commit 2593f98

Please sign in to comment.