小编CYL*_*CYL的帖子

Angular:使用“GitHub”页面重新加载后获取“404”

我已Angular在页面上部署了我的网站GitHub,但遇到了问题。

以下是我的route设置:

const routes: Routes = [
  { path: '', redirectTo: 'main', pathMatch: 'full' },
  { path: 'main', component: AppMainComponent }
];
Run Code Online (Sandbox Code Playgroud)

以下是我的部署命令:

- name: Build
        run: |
          npm install -g @angular/cli
          npm install
          ng build --prod --base-href=https://[user-name].github.io/[project-name]/
        
- name: Deploy
        uses: JamesIves/github-pages-deploy-action@releases/v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BASE_BRANCH: master
          BRANCH: gh-pages
          FOLDER: dist/[project-name]
Run Code Online (Sandbox Code Playgroud)

如果我转到我的GitHub页面“https://[user-name].github.io/[project-name]/”,它工作正常并重定向到“https://[user-name].github.io” /[项目名称]/main”成功。但是当我单击浏览器的重新加载按钮后,它404 page not found向我显示了。

我的 Angular 版本是 9.1.8。

谢谢!

github-pages angular

3
推荐指数
1
解决办法
1911
查看次数

标签 统计

angular ×1

github-pages ×1