From 74267228ba0efe34db211349deed7dbc219ccc36 Mon Sep 17 00:00:00 2001 From: Kalila L Date: Fri, 1 Oct 2021 03:00:42 -0400 Subject: [PATCH] Make Axios header application conditional. --- .../resources/web/web-new/src/boot/axios.ts | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/domain-server/resources/web/web-new/src/boot/axios.ts b/domain-server/resources/web/web-new/src/boot/axios.ts index 4d02170e22..92097bc61b 100644 --- a/domain-server/resources/web/web-new/src/boot/axios.ts +++ b/domain-server/resources/web/web-new/src/boot/axios.ts @@ -18,12 +18,20 @@ declare module "@vue/runtime-core" { Log.info(Log.types.OTHER, "Bootstrapping Axios."); -// This is a necessary header to be passed to the Metaverse server in order for -// it to fail with an HTTP error code instead of succeeding and returning -// the error in JSON only. -axios.defaults.headers.common = { - "x-vircadia-error-handle": "badrequest" -}; +// TODO: This needs to be centralized and not hardcoded. +const METAVERSE_URL = "https://metaverse.vircadia.com/live"; +axios.interceptors.request.use((config) => { + // This is a necessary header to be passed to the Metaverse server in order for + // it to fail with an HTTP error code instead of succeeding and returning + // the error in JSON only. + if (config.url?.includes(METAVERSE_URL)) { + config.headers["x-vircadia-error-handle"] = "badrequest"; + } + console.info("config", config); + return config; +}, (error) => { + return Promise.reject(error); +}); // Be careful when using SSR for cross-request state pollution // due to creating a Singleton instance here;