fix(papermark): patch middleware to allow IP-based access in self-hosted mode

isCustomDomain() in middleware.ts treats any non-localhost/papermark.*/vercel
host as a custom domain in production, causing DomainMiddleware to redirect
/ to https://www.papermark.com when no Redis entry exists.
Fix: patch middleware.ts before build to exclude IP addresses from custom
domain detection.
This commit is contained in:
CanbiZ (MickLesk)
2026-04-17 08:55:30 +02:00
parent cc06daf580
commit f902c9fe2f

View File

@@ -43,6 +43,17 @@ EOF
$STD npm install
$STD npx prisma generate
$STD npx prisma migrate deploy
# Patch middleware to treat IP addresses as app host (not custom domains)
# Without this, accessing via IP redirects to https://www.papermark.com
node -e "
const fs = require('fs');
let c = fs.readFileSync('middleware.ts', 'utf8');
c = c.replace(
'host?.endsWith(\".vercel.app\")',
'host?.endsWith(\".vercel.app\") || /^[\\\\d.:]+\$/.test(host || \"\")'
);
fs.writeFileSync('middleware.ts', c);
"
NODE_OPTIONS="--max-old-space-size=3584" $STD npm run build
msg_ok "Set up Papermark"