pi-web icon indicating copy to clipboard operation
pi-web copied to clipboard

CSRF check fails when running as PWA (Android "Add to Home Screen")

Open lyun00765-commits opened this issue 4 months ago • 1 comments

Environment

  • pi-web version: 0.8.2
  • pi version: 0.82.1
  • Device: Android 16 (Termux)
  • Node.js: 24.18.0

Steps to reproduce

  1. Open pi-web in Chrome on Android at http://127.0.0.1:30141
  2. Click the menu → "Add to Home Screen" / "安装应用"
  3. Open the installed PWA shortcut
  4. Click the history button (counter-clockwise clock icon) in the top bar

Expected

History panel opens normally.

Actual

Returns error: {"error":"Untrusted API request"}

Additional context

  • Works fine in the browser directly, only fails in PWA mode
  • Likely caused by Sec-Fetch-Site header being different in PWA WebView
  • Also related: new URL(request.url) in the CSRF check uses a relative path (e.g. /api/plugins) instead of a full URL in Next.js route handlers

lyun00765-commits avatar Jul 29 '26 12:07 lyun00765-commits

fixed in d3627646887908a95890e3f09c5a08fc6b9d8d31

agegr avatar Jul 29 '26 16:07 agegr