setting url strategy fails when flutter web app is pushed to github pages
Closed this issue · 2 comments
rmrbytes commented
Hello:
- The Flutter Web app has two pages:
main
andterms
. - When
setPathUrlStrategy();
it works in debug mode - But when pushed to Github pages it fails
- Below is relevant code
...
import 'package:url_strategy/url_strategy.dart';
...
void main() {
setPathUrlStrategy();
runApp(const MyApp());
}
...
...
@override
Widget build(BuildContext context) {
return MaterialApp(
initialRoute: '/',
routes: {
'/': (context) => MyHomePage(),
'/terms': (context) => TermsPage(),
},
);
}
When running locally using flutter run -d chrome
, I can access the two pages using localhost:xxxx/
and localhost:xxxx/terms
but the same does not work when the build/web directory has been pushed to github pages. In Github pages, the main page loads but the /terms
url fails.
If I do not set the url strategy then .../#/
loads the home page and ../#/terms
loads the terms page.
Is there some other settings that needs to be updated. Thanks
creativecreatorormaybenot commented
hi, thanks for using the package!
This is, however, not an issue with the package (nor Flutter). This is just based on how GitHub Pages works.
Please refer to: https://github.com/rafgraph/spa-github-pages
rmrbytes commented
Thanks for the clarification