diff --git a/webapp/backend/apiserver/controllers/imageController.js b/webapp/backend/apiserver/controllers/imageController.js index 3dbbd1551181e245ecc3efe717078f02a27a0c5a..ffd59cbca279f7d98880e46638182feba5dbdd2d 100644 --- a/webapp/backend/apiserver/controllers/imageController.js +++ b/webapp/backend/apiserver/controllers/imageController.js @@ -32,6 +32,11 @@ exports.buildFullImageUrl = (objectName) => { return `http://${MINIO.PUBLIC_ENDPOINT}:${MINIO.PORT}/${objectName}`; } +exports.removeHostFromImageUrl = (imageUrl) => { + const url = new URL(imageUrl); + return url.pathname; +} + exports.uploadImage = async (req, res) => { upload.single('image')(req, res, async (err) => { if (err) { diff --git a/webapp/backend/apiserver/controllers/userController.js b/webapp/backend/apiserver/controllers/userController.js index 898238f3027a9ba67c1b29c4869e73a3e1ee7eea..b5f5f7f311a5c8d05827e95dfb352d80098347c4 100644 --- a/webapp/backend/apiserver/controllers/userController.js +++ b/webapp/backend/apiserver/controllers/userController.js @@ -9,7 +9,7 @@ const Crew = require('../models/Crew'); const Event = require('../models/Event'); const UserCrew = require('../models/UserCrew'); const EventParticipants = require('../models/EventParticipants'); -const {buildFullImageUrl} = require('./imageController'); +const {buildFullImageUrl, removeHostFromImageUrl} = require('./imageController'); const authTokenExpiryTime = '1h'; const listItemsPerPage = 10; @@ -245,7 +245,7 @@ exports.updateUser = async (req, res) => { userProfile = await user.getProfile({transaction: tx}); if (userProfile) { // TODO: Save the image to storage and save the URL to the database - if (profile.profileImage) userProfile.profileImage = profile.profileImage; + if (profile.profileImage) userProfile.profileImage = removeHostFromImageUrl(profile.profileImage); if (profile.regionID) userProfile.regionID = profile.regionID; if (profile.job) userProfile.job = profile.job; if (profile.birthDate) userProfile.birthDate = profile.birthDate;