diff --git a/.htaccess b/.htaccess deleted file mode 100644 index 8487312bd..000000000 --- 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" - diff --git a/create-htaccess.js b/create-htaccess.js new file mode 100644 index 000000000..2a2c8ba22 --- /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 f0935e084..a549e4b8b 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",