Skip to content

Commit

Permalink
Remove unecessary config handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bischofmax committed Dec 11, 2024
1 parent e8186a1 commit 925b25b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ data:
NODE_ENV: "production"
TZ: "Europe/Berlin"
PORT: "3046"
CONFIG_PATH: "/api/v3/config/public"
35 changes: 1 addition & 34 deletions src/configuration/api/api.configuration.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,8 @@
// remove this code by BC-7906
// set CONFIG_PATH to /api/tldraw/config/public
// remove line 7 and 8 in ngnix.conf.template
import { HttpStatusCode } from "../../types/StatusCodeEnums";
import { setErrorData } from "../../utils/errorData";
import { redirectToErrorPage } from "../../utils/redirectUtils";

const getConfigOptions = async (): Promise<{
CONFIG_PATH: string;
}> => {
const connectionOptions = {
CONFIG_PATH: `/api/tldraw/config/public`,
};

if (import.meta.env.PROD) {
try {
const response = await fetch("/tldraw-client-runtime.config.json");

if (!response.ok) {
throw new Error(`${response.status} - ${response.statusText}`);
}

const data: { CONFIG_PATH: string } = await response.json();
connectionOptions.CONFIG_PATH = data.CONFIG_PATH;
} catch (error) {
setErrorData(HttpStatusCode.InternalServerError, "error.500");
redirectToErrorPage();
}
}

return connectionOptions;
};

export const API = {
FILE_UPLOAD: "/api/v3/file/upload/school/SCHOOLID/boardnodes/CONTEXTID",
FILE_DELETE: "/api/v3/file/delete/FILERECORD_ID",
FILE_RESTORE: "/api/v3/file/restore/FILERECORD_ID",
LOGIN_REDIRECT: "/login?redirect=/tldraw?parentId=PARENTID",
USER_DATA: `/api/v3/user/me`,
CONFIG_PATH: await getConfigOptions().then((options) => options.CONFIG_PATH),
CONFIG_PATH: `/api/tldraw/config/public`,
};

0 comments on commit 925b25b

Please sign in to comment.