소스 검색

Add current time as query string to end of picture url to force browsers to reload the new image

sbkwgh 7 년 전
부모
커밋
5488a3af95
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      routes/user.js

+ 5 - 3
routes/user.js

@@ -246,13 +246,15 @@ router.post('/:username/picture', upload.single('picture'), async (req, res) =>
 			if(!picture) {
 				picture = await ProfilePicture.create(pictureObj)
 				await picture.setUser(user)
-				await user.update({
-					picture: '/api/v1/user/' + req.session.username + '/picture'
-				})
 			} else {
 				await picture.update(pictureObj)
 			}
 
+			//Add random query to end to force browser to reload background images
+			await user.update({
+				picture: '/api/v1/user/' + req.session.username + '/picture?rand=' + Date.now()
+			})
+
 			res.json(user.toJSON())
 		}
 	} catch (e) {