【问题标题】:Requested URL not found when refresh the page刷新页面时找不到请求的 URL
【发布时间】:2019-06-09 14:25:14
【问题描述】:

我正在使用 react js 和 nodejs 开发一个应用程序。当我在本地机器上运行该应用程序时,它作为示例正常工作

  1. localhost:3000/Instagram/服务
  2. 本地主机:3000

当我刷新上述 URL 时,它会显示正确的网页。 我在 Google App Engine 中部署此应用程序,当我刷新以下页面时,它显示未找到请求的 URL。谁能告诉我这是什么原因?

  1. www.mydomain.com/Instagram/Services

【问题讨论】:

  • 您在开发者控制台日志中看到的失败请求是什么?
  • 也提供 app.yaml。可能是文件的配置导致了问题。

标签: node.js reactjs express google-app-engine react-router


【解决方案1】:

这可能是因为您使用的是 browserRouter 并且没有在您的 app.yaml 中正确配置适当的处理程序。你可以找到它的详细信息here

你可以这样写:

handlers:
- url: /(.*)
static_files: /index.html
upload: /index.html

您也可以使用 hashRouter,但您需要在每个路由中添加 /#/。

【讨论】:

  • 让我知道下面是错误的运行时:nodejs8 handlers: - url: /api/.* #secure: always #redirect_http_response_code: 301 script: auto - url: /.* static_files: build/index .html 上传:build/index.html - url:/static_dir: build
  • 把那个 static_dir 拿出来
猜你喜欢
  • 2017-09-22
  • 2021-08-15
  • 1970-01-01
  • 2020-12-07
  • 1970-01-01
  • 1970-01-01
  • 2016-03-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多