From a038bde743a414dc2edc39d384f68b88f0cf7384 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Fri, 4 May 2018 21:35:38 -0600 Subject: [PATCH] Fix CORS issue --- lib/themefunctions.php | 8 ++++++-- public/themes/.htaccess | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 public/themes/.htaccess diff --git a/lib/themefunctions.php b/lib/themefunctions.php index e26f2d8..dc53867 100644 --- a/lib/themefunctions.php +++ b/lib/themefunctions.php @@ -220,7 +220,11 @@ function get_setting($key, $echo = false) { function get_theme_url($echo = true) { $db = getdatabase(); $site = $db->get('sites', ["sitename", "url", "theme"], ["siteid" => getsiteid()]); - $url = formatsiteurl($site["url"]) . "themes/" . SITE_THEME; + if (isset($_GET['edit']) || isset($_GET['in_sw'])) { + $url = URL . "/public/themes/" . SITE_THEME; + } else { + $url = formatsiteurl($site["url"]) . "themes/" . SITE_THEME; + } if ($echo) { echo $url; } else { @@ -240,7 +244,7 @@ function get_theme_color_url($echo = true) { if (!file_exists(__DIR__ . "/../public/themes/" . SITE_THEME . "/colors/" . $site['color'])) { $site['color'] = "default"; } - $url = formatsiteurl($site["url"]) . "themes/" . SITE_THEME . "/colors/" . $site["color"]; + $url = get_theme_url(false) . "/colors/" . $site["color"]; if ($echo) { echo $url; } else { diff --git a/public/themes/.htaccess b/public/themes/.htaccess new file mode 100644 index 0000000..c87d46d --- /dev/null +++ b/public/themes/.htaccess @@ -0,0 +1,3 @@ + + Header set Access-Control-Allow-Origin "*" + \ No newline at end of file