diff --git a/client/.env b/client/.env index ec1a91b..0085551 100644 --- a/client/.env +++ b/client/.env @@ -1 +1,4 @@ REACT_APP_VERSION=1.20.1 +REACT_APP_SERVER_BASE_URL=http://localhost:1337 +PUBLIC_URL=http://localhost/planka-a-moi/ +BASE_URL=/planka/ diff --git a/client/README.md b/client/README.md index d1ee58f..02fccb6 100755 --- a/client/README.md +++ b/client/README.md @@ -1 +1,9 @@ # Planka client + +## IIS install +The build package for IIS requires URL rewrite module https://www.iis.net/downloads/microsoft/url-rewrite +The web.config file is provided as is and should be enough. You might have to modify it to suit your needs. + +## Apache install +The build package for Apache requires mod_rewrite module https://httpd.apache.org/docs/2.4/fr/mod/mod_rewrite.html +The .htaccess file is provided as is and should be enough. You might have to modify it to suit your needs. diff --git a/client/config-overrides.js b/client/config-overrides.js index 2ea9da5..80956a5 100644 --- a/client/config-overrides.js +++ b/client/config-overrides.js @@ -32,7 +32,15 @@ const replaceBaseUrl = (compiler) => { replaceInFile(info.targetPath, `"${BASE_URL_PLACEHOLDER}"`, '`${window.BASE_URL}/`'); } else if (/index\.html$/.exec(info.targetPath)) { // For the main html file, we set a placeholder for sails to inject the correct value as runtime - replaceInFile(info.targetPath, BASE_URL_PLACEHOLDER, '<%= BASE_URL %>'); + if (process.argv.indexOf('--IIS') >= 0 || process.argv.indexOf('--APACHE') >= 0) { + if (process.env.PUBLIC_URL === undefined) { + // eslint-disable-next-line no-console + throw new Error('You have to define PUBLIC_URL in .env!'); + } + replaceInFile(info.targetPath, BASE_URL_PLACEHOLDER, process.env.PUBLIC_URL); + } else { + replaceInFile(info.targetPath, BASE_URL_PLACEHOLDER, '<%= BASE_URL %>'); + } } } }); diff --git a/client/package.json b/client/package.json index 7e975a5..6b1a249 100755 --- a/client/package.json +++ b/client/package.json @@ -3,6 +3,8 @@ "private": true, "scripts": { "build": "react-app-rewired build", + "build:iis": "react-app-rewired build --IIS", + "build:apache": "react-app-rewired build --APACHE", "eject": "react-scripts eject", "lint": "eslint --ext js,jsx src config-overrides.js", "start": "react-app-rewired start", diff --git a/client/public/.htaccess b/client/public/.htaccess new file mode 100644 index 0000000..67e22dd --- /dev/null +++ b/client/public/.htaccess @@ -0,0 +1,7 @@ +Options -MultiViews + + + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^ index.html [QSA,L] + diff --git a/client/public/web.config b/client/public/web.config new file mode 100755 index 0000000..860380b --- /dev/null +++ b/client/public/web.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + +