【发布时间】:2019-11-01 21:40:14
【问题描述】:
我有一个 Gatsby 博客。我正在为 create-react-app 中的编码游戏编写一组教程文章。在我的 Gatsby 帖子降价中,我试图链接到托管在同一服务器上的那个帖子的演示反应应用程序的构建版本,但 Gatsby 一直给我一个 404 页面。
我正在使用 nginx。由gatsby build 生成的公用文件夹的所有内容都位于我的网络服务器的var/www/html 目录中。
create-react-app 构建位于 var/www/html/tutorials/01/ 内,并有自己的 index.html 文件。
在我的 Markdown 中,我尝试了这两种格式的链接:view the code [here](/tutorials/01/) 和 view the code [here](//165.227.94.249/tutorials/01/)。
如果您在浏览器中查看帖子,网址为 //165.227.94.249/posts/tutorial-01 并单击链接,它将带您到 //165.227.94.249/tutorials/01/ 但会显示404 页面。但是,如果您在相同的 URL 刷新浏览器,将提供工作的 react 应用程序。
如何防止 Gatsby 覆盖此请求并显示 404 页面,而不仅仅是让 Web 服务器提供该 URL 中存在的 index.html 文件?
【问题讨论】:
标签: nginx create-react-app gatsby