simpleclub/url_strategy

setting url strategy fails when flutter web app is pushed to github pages

Closed this issue · 2 comments

Hello:

  1. The Flutter Web app has two pages: main and terms.
  2. When setPathUrlStrategy(); it works in debug mode
  3. But when pushed to Github pages it fails
  4. 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

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

Thanks for the clarification