diff options
author | Shefali Joshi <simplyrender@gmail.com> | 2022-08-26 02:09:45 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-26 02:09:45 +0300 |
commit | a73719e8094be6d6971a0b3ee5ea6c4ab4610518 (patch) | |
tree | 317a3c372ee6a812ed619cfb04b8557fe1fcf890 | |
parent | fcfa95c2df60a45fd766a33ac507ab79537f4b93 (diff) | |
parent | 798e2d4337fdb735c23fafa2118910a2695109ef (diff) |
Merge branch 'master' into fix-gaugefix-gauge
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | src/plugins/persistence/couch/setup-couchdb.sh | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/package.json b/package.json index 462d4d0d2..4add9a776 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "mini-css-extract-plugin": "2.6.1", "moment": "2.29.4", "moment-duration-format": "2.3.2", - "moment-timezone": "0.5.34", + "moment-timezone": "0.5.37", "nyc":"15.1.0", "painterro": "1.2.78", "plotly.js-basic-dist": "2.14.0", diff --git a/src/plugins/persistence/couch/setup-couchdb.sh b/src/plugins/persistence/couch/setup-couchdb.sh index f07fc9470..2b8f5e7c1 100644 --- a/src/plugins/persistence/couch/setup-couchdb.sh +++ b/src/plugins/persistence/couch/setup-couchdb.sh @@ -83,6 +83,18 @@ create_admin_user () { curl -X PUT $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/admins/$COUCH_ADMIN_USER -d \'"$COUCH_ADMIN_PASSWORD"\' } +is_cors_enabled() { + resource_exists $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/httpd/enable_cors +} + +enable_cors () { + curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/httpd/enable_cors -d '"true"' + curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/cors/origins -d '"http://localhost:8080"' + curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/cors/credentials -d '"true"' + curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/cors/methods -d '"GET, PUT, POST, HEAD, DELETE"' + curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/cors/headers -d '"accept, authorization, content-type, origin, referer, x-csrf-token"' +} + if [ "$(admin_user_exists)" == "FALSE" ]; then echo "Admin user does not exist, creating..." create_admin_user @@ -123,3 +135,10 @@ if [ "{\"ok\":true}" == "${response}" ]; then else echo "Database permissions not updated" fi + +if [ "FALSE" == $(is_cors_enabled) ]; then + echo "Enabling CORS" + enable_cors +else + echo "CORS enabled, nothing to do" +fi |