plus_plugins
plus_plugins copied to clipboard
[package_info_plus][web] can not load version.json when URI path contains index.html
Our Flutter web app is embedded in iframe of an external web platform using some URI pattern like https://external-domain.com/index.html
. Because the path contains index.html
package_info_plus_web fails to load version information from version.json
.
System info
Platform the Issue occurs on: web Plugin name: package_info_plus_web Plugin version: 1.0.5
Steps to Reproduce
Create a local Flutter app with a sample page which is available as
http://127.0.0.1:8081/#/my-sample-page
The same page should be available when we modify the path like
http://127.0.0.1:8081/index.html#/my-sample-page
Using the second URI the path in versionJsonUrl
is wrong so the method fails to load version.json
In our case it would be sufficient to just remove the special case of index.html
from the path in versionJsonUrl
, e.g.:
/// Get version.json full url.
Uri versionJsonUrl(String baseUrl, int cacheBuster) {
final baseUri = Uri.parse(baseUrl);
final originPath =
'${baseUri.origin}${baseUri.path.replaceAll('index.html', '')}';
final versionJson = 'version.json?cachebuster=$cacheBuster';
return Uri.parse(originPath.endsWith('/')
? '$originPath$versionJson'
: '$originPath/$versionJson');
}
But maybe this issue needs a more general solution?
I have similar problem. Package is working on local host but return empty in release. (event without any index.html). I had to load version.json
manually.
Same issue, version.json does not load. Not in debug localhost, or on release server.
I have similar problem. Package is working on local host but return empty in release. (event without any index.html). I had to load
version.json
manually.
What do you mean by "load version.json
manually"? How did you do that?
When you build your web app, there will be a file named version.json
and you can call it as an API directly.
the URL will be something like
you.domain.com/version.json
it will return a JSON file that contains version name and version number.
but as I tested this on two servers, the first one returns an HTML page so you cant use it as a JSON response and encoded it. on the other hand, the second servers return a JSON response.
by the way, this package on the web is also called this URL to get the info, and when it tries to decode the response an exception will throw, so it returns an empty response. for the final solution, I have a static version number and version name and have a TODO on it so every time I am going to update the version I update this static too. and where I want to get this info at first try to load the JSON file and if it throws an exception I return this static as the response.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days