chore: 🤖 add support for API_HOST build-time config

This commit is contained in:
Randall Morey committed 2020-05-20 11:47:31 -04:00
1 parent bf72b02efd
commit e6bbdcbcf4
5 files changed
+20 -1

No files matched your search

+1
View File
@@ -72,6 +72,7 @@ These environment variables may be used to customized the build.
| Variable | Default Value | Description |
| -------- | ------------- | ----------- |
| `APP_NAME` | Application Name | The user-facing name of the application, appearing in titles, etc. |
| `API_HOST` | | The host of the API, if different than UI (e.g. https://example.net:1234). |
### Running Tests
+7
View File
@@ -1,6 +1,7 @@
'use strict';
const APP_NAME = process.env.APP_NAME || 'Application Name';
const API_HOST = process.env.API_HOST || 'http://localhost:9200';
module.exports = function (environment) {
let ENV = {
@@ -26,6 +27,7 @@ module.exports = function (environment) {
},
api: {
host: API_HOST,
namespace: 'v1',
},
@@ -71,6 +73,11 @@ module.exports = function (environment) {
};
enableUnsafeCSP();
// TODO: should provide an env var to explicitly add a host to CSP
// at build time for any environment (not just development),
// rather than automatically include API_HOST. Changes to CSP should
// be explicit.
if (API_HOST) ENV.contentSecurityPolicy['connect-src'].push(API_HOST);
}
if (environment === 'test') {
+3
View File
@@ -21,5 +21,8 @@ export default function() {
https://www.ember-cli-mirage.com/docs/route-handlers/shorthands
*/
if (config.api.host) this.passthrough(`${config.api.host}/**`);
this.passthrough();
this.get('/orgs/:org_id/projects');
}