flutter_cached_network_image
flutter_cached_network_image copied to clipboard
Headers are being ignored on Web platform
🐛 Bug Report
Trying to add a token to the request headers but it's not being added
Expected behavior
Token is added to the request headers
Reproduction steps
final headers = {"Authorization": "Bearer #token# "};
CachedNetworkImage( width: _width, height: _height, imageUrl: imageUrl ?? '', httpHeaders: headers, placeholder: (context, url) => CircularProgressIndicator(), errorWidget: (context, url, error) { print (error.toString()); return Icon(Icons.error);}, imageBuilder: (context, image) => CircleAvatar( backgroundImage: image, radius: 150, ), ),
Also tried to use http client with an interceptor http_interceptor: ^1.0.2 but failed as well:
final client = InterceptedClient.build(interceptors: [ CachedImageInterceptor(_token), ]);
cacheManager: CacheManager( Config( 'cached_images', fileService: HttpFileService( httpClient: client, ), ), ),
In both cases the header is not added. Looks like headers are ignored or http client is overridden at some point later
Configuration
Version: 3.1.0
Platform: Web
Flutter Doctor: [✓] Flutter (Channel stable, 2.5.1, on macOS 11.6 20G165 darwin-x64) • Flutter version 2.5.1 at ... • Upstream repository https://github.com/flutter/flutter.git • Framework revision ffb2ecea52 (7 weeks ago), 2021-09-17 15:26:33 -0400 • Engine revision b3af521a05 • Dart version 2.14.2
[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] IntelliJ IDEA Community Edition (version 2021.2.2) • IntelliJ at /Applications/IntelliJ IDEA CE.app • Flutter plugin version 61.2.4 • Dart plugin version 212.5486
[✓] Connected device (1 available) • Chrome (web) • chrome • web-javascript • Google Chrome 95.0.4638.69
I guess my issue is the same as this one? https://github.com/flutter/flutter/issues/57187
i have similar issue
I'm also having this issue in version 3.2.0
version 3.2.3 still not work.Image.network can added to the request headers.
Is there a known workaround or fix I can use to get this working? Just ran into this on web.
@KuroodoD just for web use Image.network()
kIsWeb ? Image.network() : CachedNetworkImage()