fix: Convert relative image URLs to full InvenTree URLs in web app

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 <noreply@anthropic.com>
This commit is contained in:
2025-10-29 11:33:58 +07:00
parent 8dadd66f45
commit 0fb4170549

View File

@@ -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