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

Deployed my Angular app on GitHub pages but errors coming on website in console

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

这是我的 GitHub 存储库 link: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 ()

您的脚本位于 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 标志构建项目并在 index.htmlsee the documentation for more information.

中设置 <base href> 标记来设置这些路径

在您的情况下,这会导致

ng build --base-href=/Ice-and-Fire/

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

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

</html>