返回到我的项目时显示 GitHub 中未找到 404 错误文件发布

showing 404 error file not found in GitHub publish when come back to my project

当我上传到 GitHub 并成功发布时,我有一个简单的静态 Web 应用程序,它会实时显示,但问题是当我单击外部 link 并再次使用 chrome 的后退箭头返回然后它像这样显示我并假设在我的应用程序中我提到了 link 像 <a href="https://facebook.com"></a> 然后返回错误显示如下这个你可以检查下面的错误。

404
File not found

The site configured at this address does not contain the requested file.

If this is your site, make sure that the filename case matches the URL.
For root URLs (like http://example.com/) you must provide an index.html file.

这是我在 GitHub 上的 Dist 文件夹,您可以看到 index.html 在那里,然后它还显示错误 404 找不到文件。

我更喜欢这个解决方案,但对我不起作用这是 Link,我找到了很多资源,但没有用。

我从两方面都尝试过,首先我尝试使用 GUI,但它不起作用,然后使用 CLI 它工作正常首先不要使用 CLI 从 GUI 发布,因为我们不需要上传手动创建 dist 文件,对于 dist 文件,我们将使用其他命令制作 dist 文件,并将该 dist 文件直接上传到 GitHub.

一件事是不要像这样创建存储库 username.github.io 创建一个名称简单的存储库,例如 testsample随便你。

要部署您的 Angular 应用程序,请先在 GitHub 上创建一个存储库。为此,请导航到 https://github.com/ 并单击“新建存储库”。我正在创建一个名为 "testing"

的存储库

当你遇到这样的错误时,在执行下面的步骤之前'git' is not recognized as an internal or external command, operable program or batch file.

然后你需要安装 git 形式 Here

存储库创建后,使用git 命令将此存储库作为远程文件添加到本地项目。为此,运行 下面的命令:

git remote add origin https://github.com/USERNAME/PROJECT_NAME.git

不要忘记更改用户名和项目名称。添加远程存储库后,您可以使用以下命令进行验证:

git remote -v

您将获得存储库列表

要将 Angular 应用程序部署到 GitHub,您需要首先全局安装 angular-cli-ghpages:

npm install -g angular-cli-ghpages

安装ghpages后,使用AngularCLI构建项目。为此,运行 命令如下所示:

ng build --prod --base-href https://<username>.github.io/testing/

最后一步,运行命令ngh -no-silent发布应用程序

成功发布您的应用后,导航至 https://<username>.github.io/<testing>/ 以在 GitHub 上查看它。这就是将 Angular 应用程序部署到 GitHub.

所需要做的全部工作

您将在存储库设置下获得发布 link,只需向下滚动到 github pages