Search code examples
fluttergithubgithub-pagesflutter-web

GitHub Pages redirects to a different site


So I'm trying to deploy my flutter web app using GitHub pages, but I'm facing a weird issue. So I have my portfolio on imgkl.github.io and I'm trying to deploy another app called fl_catalogue which has the URL, imgkl.github.io/fl_catalogue/. But when I try to go to the fl_catalogue app, it takes me to my portfolio.

my portfolio

fl_catalogue

I'm deploying the site, using this workflow.

name: Flutter Web
on:
push:
branches:
  - master
jobs:
 build:
   name: Build Web
   env:
     my_secret: ${{secrets.commit_secret}}
   runs-on: ubuntu-latest
   steps:
      - uses: actions/checkout@v1
      - uses: subosito/flutter-action@v1
        with:
           channel: 'beta'
      - run: flutter config --enable-web
      - run: flutter pub get
      - run: flutter build web --release
      - run: |
          cd build/web
          git init
          git config --global user.email my_email
          git config --global user.name Imgkl
          git status
          git remote add origin https://${{secrets.commit_secret}}@github.com/Imgkl/fl_catalogue.git
          git checkout -b gh-pages
          git add --all
          git commit -m "update"
          git push origin gh-pages -f

Solution

  • You probably did not change the base path in web/index.html

      <!--
        If you are serving your web app in a path other than the root, change the
        href value below to reflect the base path you are serving from.
    
        The path provided below has to start and end with a slash "/" in order for
        it to work correctly.
    
        Fore more details:
        * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
      -->
      <base href="/">