Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MateCat-Noble/MateCatApache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ RUN #phpenmod mcrypt

COPY run_plugin_js_build.sh /tmp/run_plugin_js_build.sh
COPY run.sh /tmp/run.sh
COPY vite-proxy.sh /usr/local/bin/vite-proxy
RUN chmod +x /tmp/run_plugin_js_build.sh
RUN chmod +x /tmp/run.sh
RUN chmod +x /usr/local/bin/vite-proxy

WORKDIR "/var/www/matecat"
CMD ["/tmp/run.sh"]
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


<VirtualHost *:443>
#IncludeOptional /etc/apache2/vite-dev-proxy.inc

ServerAdmin webmaster@localhost
ServerName dev.matecat.com
Expand Down
44 changes: 44 additions & 0 deletions MateCat-Noble/MateCatApache/data/etc/apache2/vite-dev-proxy.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Vite dev server reverse proxy (included from VirtualHost)
# Toggle with: vite-proxy on|off|status

# Disable caching for proxied paths
<LocationMatch "^/((@vite|@react-refresh|@fs|vite-entries|__vite_hmr|node_modules)(/|$))">
ExpiresActive Off
Header always unset Expires
Header always set Cache-Control "no-store"
</LocationMatch>
<LocationMatch "^/public/">
ExpiresActive Off
Header always unset Expires
Header always set Cache-Control "no-store"
</LocationMatch>

# HMR WebSocket
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/__vite_hmr(.*)$ "ws://127.0.0.1:5173/__vite_hmr$1" [P,L]

# Proxy Vite paths (before .htaccess static file serving)
ProxyPass "/__vite_hmr" "ws://127.0.0.1:5173/__vite_hmr"
ProxyPassReverse "/__vite_hmr" "ws://127.0.0.1:5173/__vite_hmr"
ProxyPass "/@vite" "http://127.0.0.1:5173/@vite"
ProxyPassReverse "/@vite" "http://127.0.0.1:5173/@vite"
ProxyPass "/@react-refresh" "http://127.0.0.1:5173/@react-refresh"
ProxyPassReverse "/@react-refresh" "http://127.0.0.1:5173/@react-refresh"
ProxyPass "/@fs/" "http://127.0.0.1:5173/@fs/"
ProxyPassReverse "/@fs/" "http://127.0.0.1:5173/@fs/"
ProxyPass "/vite-entries/" "http://127.0.0.1:5173/vite-entries/"
ProxyPassReverse "/vite-entries/" "http://127.0.0.1:5173/vite-entries/"
ProxyPass "/public/" "http://127.0.0.1:5173/public/"
ProxyPassReverse "/public/" "http://127.0.0.1:5173/public/"
ProxyPass "/plugins/" "http://127.0.0.1:5173/plugins/"
ProxyPassReverse "/plugins/" "http://127.0.0.1:5173/plugins/"
ProxyPass "/node_modules/" "http://127.0.0.1:5173/node_modules/"
ProxyPassReverse "/node_modules/" "http://127.0.0.1:5173/node_modules/"

SetEnv VITE_DEV 1

# Longer timeout for Vite (SCSS compilation can be slow on first load)
<Proxy "http://127.0.0.1:5173/*">
ProxySet timeout=120
</Proxy>
29 changes: 29 additions & 0 deletions MateCat-Noble/MateCatApache/vite-proxy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# Toggle Vite dev server reverse proxy in Apache
# Usage: vite-proxy {on|off|status}

CONF="/etc/apache2/sites-enabled/443-matecat.conf"
ENABLED="IncludeOptional /etc/apache2/vite-dev-proxy.inc"
DISABLED="#IncludeOptional /etc/apache2/vite-dev-proxy.inc"

case "$1" in
on)
sed -i "s|${DISABLED}|${ENABLED}|" "$CONF" && apachectl graceful
echo "Vite dev proxy enabled. Run 'yarn watch' to start Vite."
;;
off)
sed -i "s|${ENABLED}|${DISABLED}|" "$CONF" && apachectl graceful
echo "Vite dev proxy disabled. Apache serves static builds."
;;
status)
if grep -q "^[[:space:]]*IncludeOptional.*/vite-dev-proxy.inc" "$CONF"; then
echo "ON"
else
echo "OFF"
fi
;;
*)
echo "Usage: vite-proxy {on|off|status}"
exit 1
;;
esac