From 736f76eff647681e5c5b0cf2fc8ddde789d28541 Mon Sep 17 00:00:00 2001 From: dienamo Date: Tue, 17 Sep 2024 15:11:04 +0200 Subject: [PATCH 1/2] =?UTF-8?q?cr=C3=A9ation=20du=20.htaccess=20=C3=A0=20l?= =?UTF-8?q?a=20racine=20de=20dist=20pour=20routing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- create-htaccess.js | 18 ++++++++++++++++++ package.json | 1 + 2 files changed, 19 insertions(+) create mode 100644 create-htaccess.js diff --git a/create-htaccess.js b/create-htaccess.js new file mode 100644 index 00000000..2a2c8ba2 --- /dev/null +++ b/create-htaccess.js @@ -0,0 +1,18 @@ +const fs = require('fs'); +const path = require('path'); + +const htaccessContent = ` +RewriteEngine On + +RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR] +RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d +RewriteRule ^ - [L] + +RewriteRule ^ /index.html +`; + +const distPath = path.join(__dirname, 'dist'); +const htaccessPath = path.join(distPath, '.htaccess'); + +fs.writeFileSync(htaccessPath, htaccessContent.trim()); + diff --git a/package.json b/package.json index f0935e08..a549e4b8 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "license": "AGPL-3.0", "scripts": { "build": "vite build", + "postbuild": "node create-htaccess.js", "dev": "vite", "eject": "react-scripts eject", "lint": "eslint src --max-warnings=0 --cache --cache-location node_modules/.cache/eslint", From 8f5030e4e7167ebfbda39d55d7d0f6a9201cdd22 Mon Sep 17 00:00:00 2001 From: dienamo Date: Wed, 18 Sep 2024 17:12:35 +0200 Subject: [PATCH 2/2] :fix suppression .htaccess --- .htaccess | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 .htaccess diff --git a/.htaccess b/.htaccess deleted file mode 100644 index 8487312b..00000000 --- a/.htaccess +++ /dev/null @@ -1,9 +0,0 @@ -RewriteEngine On -DirectoryIndex index.html -RewriteCond %{REQUEST_FILENAME} !-d -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule . index.html [L] - - -Header set Cache-Control "max-age=60, private, proxy-revalidate" -