From aa57083afc5fee62092d2ae1214a8a37c04791dc Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 11 Mar 2020 17:21:07 +0100 Subject: [PATCH] :wrench: Minor changes on frontend build config. --- frontend/gulpfile.js | 15 ++++++++++----- frontend/src/uxbox/config.cljs | 18 +++++++++++++++--- frontend/src/uxbox/main/ui.cljs | 18 ------------------ 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/frontend/gulpfile.js b/frontend/gulpfile.js index 41fd60fd0..db679cf7c 100644 --- a/frontend/gulpfile.js +++ b/frontend/gulpfile.js @@ -101,13 +101,18 @@ function readLocales() { } function readConfig() { - const apiUrl = process.env.UXBOX_API_URL; + const backendURL = process.env.UXBOX_BACKEND_URL; const demoWarn = process.env.UXBOX_DEMO_WARNING; - return JSON.stringify({ - apiUrl: (apiUrl === undefined ? "http://localhost:6060" : apiUrl.trim()), - demoWarning: demoWarn === "true", - }); + let cfg = { + demoWarning: demoWarn === "true" + }; + + if (backendURL !== undefined) { + cfg.backendURL = backendURL; + } + + return JSON.stringify(cfg); } function templatePipeline(options) { diff --git a/frontend/src/uxbox/config.cljs b/frontend/src/uxbox/config.cljs index 9080abfdb..ce37abdb1 100644 --- a/frontend/src/uxbox/config.cljs +++ b/frontend/src/uxbox/config.cljs @@ -10,7 +10,19 @@ (ns uxbox.config (:require [goog.object :as gobj])) -(let [config (gobj/get goog.global "uxboxConfig")] +(defn- get-current-origin + [] + (let [location (gobj/get goog.global "location")] + (gobj/get location "origin"))) + +(let [config (gobj/get goog.global "uxboxConfig") + backend-url (gobj/get config "backendURL" "http://localhost:6060")] + (def default-language "en") - (def url (gobj/get config "apiUrl" "http://localhost:6060/")) - (def demo-warning (gobj/get config "demoWarning" true))) + (def demo-warning (gobj/get config "demoWarning" true)) + + (def url + (if (= backend-url "samesite") + (get-current-origin) + backend-url))) + diff --git a/frontend/src/uxbox/main/ui.cljs b/frontend/src/uxbox/main/ui.cljs index ba7a3023e..1ba0bd6b6 100644 --- a/frontend/src/uxbox/main/ui.cljs +++ b/frontend/src/uxbox/main/ui.cljs @@ -64,24 +64,6 @@ ["/workspace/:file-id" :workspace]]) -(defn- parse-team-id - [route profile] - (let [team-id (get-in route [:params :path :team-id])] - (cond - (uuid-str? team-id) (uuid team-id) - (= "self" team-id) (:default-team-id profile) - :else (ex/raise :type :validation - :code :invalid-team-id)))) - -(defn- parse-project-id - [route profile] - (let [project-id (get-in route [:params :path :project-id])] - (cond - (uuid-str? project-id) (uuid project-id) - (= "drafts" project-id) (:default-project-id profile) - :else (ex/raise :type :validation - :code :invalid-project-id)))) - (mf/defc app [props]