GitHub Pages 不为项目提供服务,而是呈现根用户站点 [英] GitHub Pages not serving projects, renders the root user site instead

查看:26
本文介绍了GitHub Pages 不为项目提供服务,而是呈现根用户站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从 bloom510.github.io 存储库中提供 React 应用程序.有 2 个分支:sourcemaster.正如您可能已经猜到的那样,源代码包含整个未编译的源代码,然后将其构建并部署到主分支.这有效.

我的问题是托管在 GitHub 页面上的其他项目,GitHub 声称已成功发布到 bloom510.github.io/my_project_name 只需加载包含 React 应用程序的根站点.事实上,任何任意路由加载它都不会出现 404 错误.这发生在我所有的设备上:Chromebook、MacBook 和 Pixel 2 XL.这是怎么回事?

更新:目前在/card 项目中托管我的主站点并从主站点重定向.真的很想让主站点正常工作.

我一直在使用的链接:

用户页面:

解决方案

就我而言,它看起来与 react-router-dom v4 有关.我通过更改

得到了修复

<应用程序/></路由器>

进入

<应用程序/></路由器>

似乎 react-router-dom 将您的 gh-pages 重定向到 bloom510.github.io 而不是 bloom510.github.io/my_project_name 的根目录.希望能帮到所有遇到同样问题的人.

I'm serving a React app out of the bloom510.github.io repository. There are 2 branches: source and master. As you might have guessed, source contains the entire non-compiled source code which is then built and deployed to the master branch. This works.

My problem is that other projects hosted on GitHub pages which GitHub says have been published successfully to bloom510.github.io/my_project_name simply load the root site containing the React app. In fact, any arbitrary route loads it without a 404 error. This is occurring on all my devices: Chromebook, MacBook, and Pixel 2 XL. What is going on here?

UPDATE: Currently hosting my main site in /card project and redirecting from main site. Would really like to get the main site working properly.

Links I have been working with:

user page: bloom510.github.io

a project: bloom510.github.io/hello-wasm

an arbitrary route: bloom510.github.io/i-do-not-exist

repo: https://github.com/bloom510/bloom510.github.io

解决方案

In my case, it look like it has something to do with react-router-dom v4. I got the fix by changing

<Router basename='/'>
  <App/>
</Router>

into

<Router basename='/yourCurrentRepository'>
  <App/>
</Router>

Seems like react-router-dom redirect your gh-pages into root directory wich is bloom510.github.io instead of bloom510.github.io/my_project_name. Hopefully can help everyone who is also experiencing the same problem.

这篇关于GitHub Pages 不为项目提供服务,而是呈现根用户站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆