Issue with Flutter Web App on Django Server
I'm working on hosting a Flutter web application with a Django web server on Ubuntu 20.2. My Flutter version is 3.13.5, and my project structure places the Flutter web project within the 'static' folder to allow Django to host this app (so it is kinda working).
Problem Description:
I'm encountering an issue where the Flutter web application cannot locate the 'FontManifest.json' file. It appears that this file is being sought using the current URL (relative) instead of the base URL defined in 'index.html'.
Specifics:
Assets loaded from 'index.html' work correctly with the base href directed to the 'static' directory. However, assets loaded from 'main.dart.js' (basically the engine with all the logic) use the current URL, causing issues when static assets are referenced from there.
Attempts Made:
I tried fetching the missing files 'AssetManifest.bin' and 'FontManifest.json' directly through 'main.dart.js,' but this didn't work. It seems to disrupt the loading of other static assets and fetches from external APIs in 'main.dart.js' (without even finding these assets).
In 'index.html,' I changed the base href to the 'static' folder. This fixed fetching assets referenced in 'index.html' (e.g., 'flutter.js'). However, 'main.dart.js,' responsible for app logic, still uses relative URIs for fetching intrinsic assets, causing 404s.
Seeking Solutions:
I'm looking for insights on how to ensure that all assets, including 'FontManifest.json,' loaded from 'main.dart.js,' use the base URL as intended. It seems like Flutter should provide a configuration option for specifying the static URI location where the app and its static files will be hosted. A solution I could think of is using Nginx to host those static files in those dynamic URIs that host the flutter app but I really see that as a last resort. I think the static path should be configured in Flutter.
Has anyone encountered a similar issue or found a workaround to ensure consistent asset loading?