在 GitHub 页面上部署了我的 Angular 应用程序,但在控制台中的网站上出现错误

chi*_*ag 2 github angular angular-cli-ghpages

我已经在 GitHub 页面上成功发布了我的应用程序,但我的网站没有显示任何内容。

这是我的 GitHub 存储库链接:https : //github.com/chirag299051/Ice-and-Fire

我在控制台中遇到的错误:

inline.318b50c57b4eba3d437b.bundle.js Failed to load resource: the server responded with a status of 404 ()
polyfills.b6b2cd0d4c472ac3ac12.bundle.js Failed to load resource: the server responded with a status of 404 ()
scripts.e2cc764d74d6cb8d1c42.bundle.js Failed to load resource: the server responded with a status of 404 ()
main.54e8c9147109b23af744.bundle.js Failed to load resource: the server responded with a status of 404 ()
styles.a9b0b1037568d3083749.bundle.css Failed to load resource: the server responded with a status of 404 ()
polyfills.b6b2cd0d4c472ac3ac12.bundle.js Failed to load resource: the server responded with a status of 404 ()
scripts.e2cc764d74d6cb8d1c42.bundle.js Failed to load resource: the server responded with a status of 404 ()
main.54e8c9147109b23af744.bundle.js Failed to load resource: the server responded with a status of 404 ()
styles.a9b0b1037568d3083749.bundle.css Failed to load resource: the server responded with a status of 404 ()
Run Code Online (Sandbox Code Playgroud)

Sim*_*kov 7

您的脚本驻留在 中,https://chirag299051.github.io/Ice-and-Fire而您的应用程序试图从https://chirag299051.github.io/.

使其能够从https://chirag299051.github.io/Ice-and-Fire.

例如, https://chirag299051.github.io/main.54e8c9147109b23af744.bundle.js应该是https://chirag299051.github.io/Ice-and-Fire/main.54e8c9147109b23af744.bundle.js

您可以通过使用--base-href标志构建项目并在 中设置<base href>标签来设置这些路径index.html请参阅文档以获取更多信息。

在您的情况下,这会导致

ng build --base-href=/Ice-and-Fire/
Run Code Online (Sandbox Code Playgroud)

和一个index.html看起来像这样

<html>
  <head>
    <base href="/Ice-and-Fire/">
    ...
  </head>
  <body>...</body>

</html>
Run Code Online (Sandbox Code Playgroud)