From d3123ca46cf1c1cc1906144bf9f52c8037cd2da0 Mon Sep 17 00:00:00 2001
From: Jan Vales <jan@jvales.net>
Date: Mon, 21 Jan 2019 02:22:11 +0100
Subject: [PATCH] fix CORS issue.

---
 service-website/nginx/default.conf             | 18 ++++++++++++++++++
 service-website/src/services/CamundaService.js |  6 +++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/service-website/nginx/default.conf b/service-website/nginx/default.conf
index cb80625..fc81d03 100644
--- a/service-website/nginx/default.conf
+++ b/service-website/nginx/default.conf
@@ -10,6 +10,24 @@ server {
         index  index.html index.htm;
     }
 
+    location /engine-rest/ {
+        proxy_pass http://camunda:8085;
+        client_max_body_size 1024M;
+        proxy_set_header Connection "";
+        proxy_set_header Host $http_host;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+        proxy_set_header X-Forwarded-Proto $scheme;
+        proxy_set_header X-Frame-Options SAMEORIGIN;
+        proxy_buffers 256 16k;
+        proxy_buffer_size 16k;
+        proxy_read_timeout 600s;
+        proxy_cache_revalidate on;
+        proxy_cache_min_uses 2;
+        proxy_cache_use_stale timeout;
+        proxy_cache_lock on;
+    }
+
     #error_page  404              /404.html;
 
     # redirect server error pages to the static page /50x.html
diff --git a/service-website/src/services/CamundaService.js b/service-website/src/services/CamundaService.js
index bd73ee6..79bdcfa 100644
--- a/service-website/src/services/CamundaService.js
+++ b/service-website/src/services/CamundaService.js
@@ -3,7 +3,7 @@ import axios from "axios";
 class CamundaService {
     constructor(callback) {
         this.callback = callback;
-        this.baseUrl = 'http://localhost:8085/engine-rest/';
+        this.baseUrl = '/';
         this.axiosInstance = axios.create({
             baseURL: this.baseUrl,
         });
@@ -17,7 +17,7 @@ class CamundaService {
         terms.forEach(term => {
             termsValue.push({term});
         });
-        const submitFormUrl = 'process-definition/key/sentiment-analysis/submit-form';
+        const submitFormUrl = '/engine-rest/process-definition/key/sentiment-analysis/submit-form';
         const data = {
             variables: {
                 terms: {
@@ -45,7 +45,7 @@ class CamundaService {
     }
 
     getPdfDownloadLink(id) {
-        const downloadUrl = this.baseUrl + 'process-instance/' + id + '/variables/reportPDF/data';
+        const downloadUrl = '/engine-rest/process-instance/' + id + '/variables/reportPDF/data';
         this.axiosInstance
             .get(downloadUrl)
             .then(response => {
-- 
2.43.0