From a132e97916ec9059f22a013dcea54a276b3019b3 Mon Sep 17 00:00:00 2001 From: Shawn Date: Tue, 5 Sep 2023 17:48:20 -0600 Subject: [PATCH] Add proxy to MET image requests --- lib/ui/common/controls/app_image.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/ui/common/controls/app_image.dart b/lib/ui/common/controls/app_image.dart index 300b7dd9..c3fc153a 100644 --- a/lib/ui/common/controls/app_image.dart +++ b/lib/ui/common/controls/app_image.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:image_fade/image_fade.dart'; import 'package:wonders/common_libs.dart'; import 'package:wonders/logic/common/retry_image.dart'; @@ -50,9 +51,22 @@ class _AppImageState extends State { void _updateImage() { if (widget.image == _sourceImage) return; _sourceImage = widget.image; + /// Apply proxy to MET api images + if(kIsWeb && _sourceImage is NetworkImage){ + final url = (_sourceImage as NetworkImage).url; + _sourceImage = NetworkImage(maybeAddMetProxy(url)); + } _displayImage = _capImageSize(_addRetry(_sourceImage)); } + String maybeAddMetProxy(String url) { + if (url.contains('images.metmuseum.org')) { + url = 'https://proxy.wonderous.app:8081/$url'; + return url; + } + return url; + } + @override Widget build(BuildContext context) { return ImageFade(