@boomerang-io/webapp-spa-server 1.2.2 → 1.2.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +15 -1
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -36,8 +36,11 @@ function createBoomerangServer({
|
|
|
36
36
|
NEW_RELIC_LICENSE_KEY,
|
|
37
37
|
HTML_HEAD_INJECTED_SCRIPTS,
|
|
38
38
|
BUILD_DIR = "build",
|
|
39
|
+
CORS_CONFIG,
|
|
39
40
|
} = process.env;
|
|
40
41
|
|
|
42
|
+
const appCorsConfig = parseJSONString(CORS_CONFIG) || corsConfig;
|
|
43
|
+
|
|
41
44
|
// Monitoring
|
|
42
45
|
if (NEW_RELIC_APP_NAME && NEW_RELIC_LICENSE_KEY) {
|
|
43
46
|
require("newrelic");
|
|
@@ -68,7 +71,7 @@ function createBoomerangServer({
|
|
|
68
71
|
})
|
|
69
72
|
);
|
|
70
73
|
app.disable("x-powered-by");
|
|
71
|
-
app.use(cors(
|
|
74
|
+
app.use(cors(appCorsConfig));
|
|
72
75
|
|
|
73
76
|
// Parsing
|
|
74
77
|
const bodyParser = require("body-parser");
|
|
@@ -242,4 +245,15 @@ function getInstanaScripts() {
|
|
|
242
245
|
: "";
|
|
243
246
|
}
|
|
244
247
|
|
|
248
|
+
//Check if a CORS_CONFIG from env is a valid JSON object and return it if so
|
|
249
|
+
function parseJSONString(jsonString) {
|
|
250
|
+
try {
|
|
251
|
+
const parseJSON = Boolean(jsonString) && JSON.parse(jsonString);
|
|
252
|
+
return typeof parseJSON === "object" ? parseJSON : false;
|
|
253
|
+
} catch (e) {
|
|
254
|
+
console.log(`JSON Parse error: ${e}`);
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
245
259
|
module.exports = createBoomerangServer;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boomerang-io/webapp-spa-server",
|
|
3
3
|
"description": "Webapp Server for React-based SPA w/ client-side routing",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.3-beta.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Tim Bula",
|
|
7
7
|
"email": "timrbula@gmail.com"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dotenv": "^16.0.3",
|
|
34
34
|
"express": "^4.18.2",
|
|
35
35
|
"helmet": "^6.0.0",
|
|
36
|
-
"newrelic": "^9.
|
|
36
|
+
"newrelic": "^9.2.0",
|
|
37
37
|
"serialize-javascript": "^6.0.0",
|
|
38
38
|
"yargs": "^17.6.0"
|
|
39
39
|
},
|