From 5c07b371a0894af7221b07e6935dd76d6585859e Mon Sep 17 00:00:00 2001 From: Nedim Uka Date: Thu, 26 Jul 2018 13:47:59 +0200 Subject: [PATCH] Fixed docker env bugs, and issues from PR --- backend/wp-config.php | 3 +++ docker-compose.yml | 5 ++--- docker/php/.htaccess | 11 +++++++---- frontend.dockerfile | 8 +++++--- frontend/src/actions/login/authActions.js | 9 +++------ frontend/src/config.js | 2 +- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/backend/wp-config.php b/backend/wp-config.php index fdf2cb9..e4f3898 100644 --- a/backend/wp-config.php +++ b/backend/wp-config.php @@ -55,6 +55,9 @@ define('SECURE_AUTH_SALT', 'Ku5k]% pS[eN,))rR4%JF7c5l;w(NVFvLir-:|-N07`[yp/U*J2x define('LOGGED_IN_SALT', 'AS,kWNt-W~}c(# tsmi$hEx{XD|`J28>nf~*8jsfFkc'); define('NONCE_SALT', '5}W)&1O:bSk@p=Uj1QJIuT<91:LHv+`Ix=;y37LaPwNWa&EW$;E~jU45+.-;%]2}'); +define('JWT_AUTH_SECRET_KEY', 'z={bYHD+B[NE>o${e:t~LZ]b!2n8knYwjAsRzB5`|8IM-#d/kv+#V-1900e1ia2M'); +define('JWT_AUTH_CORS_ENABLE', true); + //For case when wordpress is behind reverse proxy https -> http //With this settings, siteurl and home have to be https://.... diff --git a/docker-compose.yml b/docker-compose.yml index b860213..9271afa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,13 +20,12 @@ services: context: . dockerfile: frontend.dockerfile args: - - REACT_APP_TEST_URL - - REACT_APP_PROD_URL - - REACT_APP_DEV_URL + - API_URL volumes: - ./log/frontend/:/var/log/apache2/ ports: - '8080:80' + db: build: diff --git a/docker/php/.htaccess b/docker/php/.htaccess index 7135530..01ed815 100644 --- a/docker/php/.htaccess +++ b/docker/php/.htaccess @@ -1,12 +1,15 @@ - # BEGIN WordPress RewriteEngine On -RewriteBase /api/ +RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule . /api/index.php [L] +RewriteRule . /index.php [L] +RewriteCond %{HTTP:Authorization} ^(.*) +RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1] +SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 +# END WordPress + -# END WordPress \ No newline at end of file diff --git a/frontend.dockerfile b/frontend.dockerfile index b5d45fb..c2894c1 100644 --- a/frontend.dockerfile +++ b/frontend.dockerfile @@ -1,12 +1,14 @@ FROM php:7.0-apache +ARG API_URL +ENV REACT_APP_API_URL=${API_URL} ARG REACT_APP_TEST_URL ARG REACT_APP_PROD_URL ARG REACT_APP_DEV_URL -ENV REACT_APP_TEST_URL ${REACT_APP_TEST_URL} -ENV REACT_APP_PROD_URL ${REACT_APP_PROD_URL}} -ENV REACT_APP_DEV_URL ${REACT_APP_DEV_URL} +ENV REACT_APP_TEST_URL ${API_URL} +ENV REACT_APP_PROD_URL ${APIP_URL} +ENV REACT_APP_DEV_URL ${API_URL} RUN apt-get update && apt-get install -y git unzip gnupg RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - diff --git a/frontend/src/actions/login/authActions.js b/frontend/src/actions/login/authActions.js index b188efd..18867ad 100644 --- a/frontend/src/actions/login/authActions.js +++ b/frontend/src/actions/login/authActions.js @@ -38,17 +38,14 @@ export const validateAccessToken = (token) => { return dispatch => { dispatch(validateToken()); return htmlClient.fetch({ - url: `http://localhost//wp-json/jwt-auth/v1/token/validate`, + url: `${API_SERVER}/wp-json/jwt-auth/v1/token/validate`, method: 'post' }) .then(response => { - if (response.data && response.data.status === 200) { + if (response.data && response.data.data.status === 200) { // TODO: Implement refresh logic on backend as it was on old wias , or find a nother way // to handle token validation another way - - - // const serverTime = response.data.serverTime || 1; dispatch(loggedIn({ @@ -77,7 +74,7 @@ export const validateCredentials = (username, password) => { dispatch(login()); return htmlClient.fetch({ - url: `http://localhost/wp-json/jwt-auth/v1/token`, + url: `${API_SERVER}/wp-json/jwt-auth/v1/token`, method: 'post', data: { "username": username, diff --git a/frontend/src/config.js b/frontend/src/config.js index 4f77ab5..3ed8a32 100644 --- a/frontend/src/config.js +++ b/frontend/src/config.js @@ -16,6 +16,6 @@ const API_SERVER_BASE = (() => { return process.env.REACT_APP_DEV_URL; })(); -const API_SERVER = API_SERVER_BASE + '/' + API_VERSION; +const API_SERVER = API_SERVER_BASE export {APPLICAITON_MODE, API_SERVER_BASE, API_SERVER, APPLICATION_NAME}