Skip to content

Commit

Permalink
Fix public builder base url
Browse files Browse the repository at this point in the history
  • Loading branch information
olimsaidov committed Nov 11, 2024
1 parent 6194273 commit 14aa959
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 12 additions & 1 deletion aidbox-forms-smart-launch/src/hooks/use-client.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@ export const defaultScope = [
"patient/QuestionnaireResponse.crus", // Request create, read, update access to QuestionnaireResponse resource
];

export const publicBuilderClient = client("https://form-builder.aidbox.app");
const brokenUrl = "https://form-builder.aidbox.app";
const correctUrl = "https://form-builder.aidbox.app/fhir";

export const publicBuilderClient = client(correctUrl);

export const fixPotentialBrokenUrl = (url) => {
if (url.startsWith(brokenUrl) && !url.startsWith(correctUrl)) {
return url.replace(brokenUrl, correctUrl);
}

return url;
};

const clientContext = createContext(null);

Expand Down
7 changes: 5 additions & 2 deletions aidbox-forms-smart-launch/src/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";
import { publicBuilderClient } from "@/hooks/use-client.jsx";
import {
fixPotentialBrokenUrl,
publicBuilderClient,
} from "@/hooks/use-client.jsx";

export function cn(...inputs) {
return twMerge(clsx(inputs));
Expand Down Expand Up @@ -266,7 +269,7 @@ export async function findQuestionnaireWithClient(client, ref) {
.then((result) => [publicBuilderClient, unbundle(result)]),
client.request(query).then((result) => [client, unbundle(result)]),
publicBuilderClient
.request(ref)
.request(fixPotentialBrokenUrl(ref))
.then((result) => [publicBuilderClient, unbundle(result)]),
]);
}
Expand Down

0 comments on commit 14aa959

Please sign in to comment.