1

我在 GitHub 页面上部署了使用 (create-react-app) 创建的网站。

我有一个在 Github-pages 中添加的自定义 google 域

我添加了一个 CNAME 并按照所有说明进行操作

现在:1 - 如果我不使用自定义域,我可以访问我的网站,如果我去:https ://myAccount.github.io/MyWebsite/#/

2-如果我添加一个自定义域,Github 说一切都很好(见附图 1)

3- 添加自定义域并尝试访问我的新网站后,我收到以下错误: main.12d12fef.css Failed to load resource: the server responded with a status of 404 (Not Found) main.56dc6c7d.js Failed to load resource: the server responded with a status of 404 (Not Found)

4-如果我检查控制台(网络选项卡)有问题(我怀疑这是问题),请求的 URL 似乎错误(加倍):

http://www.MyWebsite.com/MyWebsite/static/js/main.89dc2c1d.js

5-这就是什么也没找到的原因 (404)

6-如果我删除 Double 并尝试访问: http://www.MyWebsite.com/static/js/main.89dc2c1d.js

我可以看到缩小的代码

问题: 为什么请求的 URL 错误?为什么是双倍的?

http://www.MyWebsite.com/MyWebsite/static/js/main.89dc2c1d.js

我怎样才能解决这个问题 ?

在此处输入图像描述

4

1 回答 1

4

好吧,我发现了问题:

问题出在我的 package.json 中,在主页键上

  • 我最初有,"homepage": "https://myGithubAccount.github.io/myWebsite"

  • 我应该改为:"homepage": "https://myWebsite.com"

现在这个问题已经通过修改解决了

于 2017-09-30T18:44:56.010 回答