From 0fb4170549c7f3e4851b38c92421a6de9c36a103 Mon Sep 17 00:00:00 2001 From: grabowski Date: Wed, 29 Oct 2025 11:33:58 +0700 Subject: [PATCH] fix: Convert relative image URLs to full InvenTree URLs in web app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes 404 errors when loading part images in the web interface. Problem: - InvenTree API returns relative image paths like /media/part_images/... - Browser tries to load from Flask app instead of InvenTree server - Results in 404 errors Solution: - Detect relative image URLs (starting with /) - Prepend InvenTree host URL to make them absolute - Apply to both image and thumbnail properties 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/stocktool/web/static/js/app.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/stocktool/web/static/js/app.js b/src/stocktool/web/static/js/app.js index 1d1b894..692337b 100644 --- a/src/stocktool/web/static/js/app.js +++ b/src/stocktool/web/static/js/app.js @@ -345,6 +345,15 @@ function stockApp() { // Part found this.currentPart = data.part_info; this.currentParameters = data.parameters; + + // Fix image URLs - convert relative paths to full InvenTree URLs + if (this.currentPart.image && this.currentPart.image.startsWith('/')) { + this.currentPart.image = this.config.host + this.currentPart.image; + } + if (this.currentPart.thumbnail && this.currentPart.thumbnail.startsWith('/')) { + this.currentPart.thumbnail = this.config.host + this.currentPart.thumbnail; + } + this.log('success', `✅ Found part: ${partCode}`); // Execute operation