From e9c0d591a904b5f4bd3814319502e89f8a9323d9 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Thu, 5 Jan 2023 11:26:44 -0500 Subject: [PATCH] add-on to inject base URL into index.html --- .env.dev | 1 + .env.production | 1 + .env.staging | 1 + app/index.html | 2 +- config/environment.js | 3 ++- lib/base-url/index.js | 15 +++++++++++++++ lib/base-url/package.json | 6 ++++++ package.json | 5 +++++ 8 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 lib/base-url/index.js create mode 100644 lib/base-url/package.json diff --git a/.env.dev b/.env.dev index 55347da4..ce179999 100644 --- a/.env.dev +++ b/.env.dev @@ -1,2 +1,3 @@ API_URL=https://api.dev.ror.org SENTRY_DSN=https://1c334995f85448b1afa561c8ccf13791@sentry.io/1422597 +BASE_URL=https://dev.ror.org diff --git a/.env.production b/.env.production index 895a7f6c..e47e9e0e 100644 --- a/.env.production +++ b/.env.production @@ -1,2 +1,3 @@ API_URL=https://api.ror.org SENTRY_DSN=https://1c334995f85448b1afa561c8ccf13791@sentry.io/1422597 +BASE_URL=https://ror.org diff --git a/.env.staging b/.env.staging index e45872cf..48631c10 100644 --- a/.env.staging +++ b/.env.staging @@ -1,2 +1,3 @@ API_URL=https://api.staging.ror.org SENTRY_DSN=https://1c334995f85448b1afa561c8ccf13791@sentry.io/1422597 +BASE_URL=https://staging.ror.org diff --git a/app/index.html b/app/index.html index 4add0b34..169fa9a8 100755 --- a/app/index.html +++ b/app/index.html @@ -18,7 +18,7 @@ - + diff --git a/config/environment.js b/config/environment.js index 9bd87282..ee8e1806 100644 --- a/config/environment.js +++ b/config/environment.js @@ -2,7 +2,7 @@ module.exports = function(environment) { const pkg = require('../package.json'); - + let ENV = { modulePrefix: 'ror-app', environment, @@ -20,6 +20,7 @@ module.exports = function(environment) { }, API_URL: process.env.API_URL || "https://api.ror.org", + BASE_URL: process.env.BASE_URL || null, SENTRY_DSN: process.env.SENTRY_DSN || null, VERSION: pkg.version, APP_NAME: pkg.name, diff --git a/lib/base-url/index.js b/lib/base-url/index.js new file mode 100644 index 00000000..2c665a94 --- /dev/null +++ b/lib/base-url/index.js @@ -0,0 +1,15 @@ +'use strict'; + +module.exports = { + name: require('./package').name, + + isDevelopingAddon() { + return true; + }, + contentFor: function(type, config){ + if (type === 'baseURL'){ + return `${config.BASE_URL}` + ; + } + } +}; diff --git a/lib/base-url/package.json b/lib/base-url/package.json new file mode 100644 index 00000000..442a2ff8 --- /dev/null +++ b/lib/base-url/package.json @@ -0,0 +1,6 @@ +{ + "name": "base-url", + "keywords": [ + "ember-addon" + ] +} diff --git a/package.json b/package.json index f21595a8..2929130b 100644 --- a/package.json +++ b/package.json @@ -66,5 +66,10 @@ "dependencies": { "@sentry/browser": "^5.10.2", "@sentry/integrations": "^5.10.2" + }, + "ember-addon": { + "paths": [ + "lib/base-url" + ] } }