Fix DrawDB: switch Caddy to Nginx, add crypto.randomUUID polyfill
- Replace Caddy with Nginx (matches upstream Dockerfile) - Add crypto.randomUUID polyfill in index.html for non-HTTPS access (browsers only expose crypto.randomUUID in secure contexts) - Apply polyfill also in update script
This commit is contained in:
@@ -36,6 +36,7 @@ function update_script() {
|
|||||||
cd /opt/drawdb
|
cd /opt/drawdb
|
||||||
$STD npm ci
|
$STD npm ci
|
||||||
NODE_OPTIONS="--max-old-space-size=4096" $STD npm run build
|
NODE_OPTIONS="--max-old-space-size=4096" $STD npm run build
|
||||||
|
sed -i '/<head>/a <script>if(!crypto.randomUUID){crypto.randomUUID=function(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,function(c){return(c^(crypto.getRandomValues(new Uint8Array(1))[0]&(15>>c/4))).toString(16)})}};</script>' /opt/drawdb/dist/index.html
|
||||||
msg_ok "Rebuilt Frontend"
|
msg_ok "Rebuilt Frontend"
|
||||||
msg_ok "Updated successfully!"
|
msg_ok "Updated successfully!"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ network_check
|
|||||||
update_os
|
update_os
|
||||||
|
|
||||||
msg_info "Installing Dependencies"
|
msg_info "Installing Dependencies"
|
||||||
$STD apt install -y caddy
|
$STD apt install -y nginx
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
NODE_VERSION="20" setup_nodejs
|
NODE_VERSION="20" setup_nodejs
|
||||||
@@ -26,16 +26,26 @@ $STD npm ci
|
|||||||
NODE_OPTIONS="--max-old-space-size=4096" $STD npm run build
|
NODE_OPTIONS="--max-old-space-size=4096" $STD npm run build
|
||||||
msg_ok "Built Frontend"
|
msg_ok "Built Frontend"
|
||||||
|
|
||||||
msg_info "Configuring Caddy"
|
msg_info "Applying crypto.randomUUID Polyfill"
|
||||||
cat <<EOF >/etc/caddy/Caddyfile
|
sed -i '/<head>/a <script>if(!crypto.randomUUID){crypto.randomUUID=function(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,function(c){return(c^(crypto.getRandomValues(new Uint8Array(1))[0]&(15>>c/4))).toString(16)})}};</script>' /opt/drawdb/dist/index.html
|
||||||
:3000 {
|
msg_ok "Applied Polyfill"
|
||||||
root * /opt/drawdb/dist
|
|
||||||
file_server
|
msg_info "Configuring Nginx"
|
||||||
try_files {path} /index.html
|
cat <<EOF >/etc/nginx/conf.d/drawdb.conf
|
||||||
|
server {
|
||||||
|
listen 3000;
|
||||||
|
server_name _;
|
||||||
|
root /opt/drawdb/dist;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files \$uri /index.html;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
systemctl reload caddy
|
rm -f /etc/nginx/sites-enabled/default
|
||||||
msg_ok "Configured Caddy"
|
systemctl enable -q --now nginx
|
||||||
|
systemctl reload nginx
|
||||||
|
msg_ok "Configured Nginx"
|
||||||
|
|
||||||
motd_ssh
|
motd_ssh
|
||||||
customize
|
customize
|
||||||
|
|||||||
Reference in New Issue
Block a user