在 GCP 上存储 React+Gatsby 静态应用程序时管理处理程序
Managing handlers when storing React+Gatsby static App on GCP
我的 React 应用程序已经 运行 在 GCP 引擎上。导航和所有页面看起来都很好,但直接链接会导致问题 - 例如,如果我打开我的网站。com/vacancies,我会收到错误日志,指出 未找到处理程序引用的静态文件: public/vacancies//index.html。
这是我的 app.yaml 处理程序配置:
handlers:
- url: /
static_files: public/index.html
upload: public/index.html
- url: /((.*\/)*[^\/]+\.[^\/]+)$
static_files: public/
upload: public/.*
- url: /(.*)$
static_files: public//index.html
upload: public/.*/index.html
解决方法是像这样打开页面 myWebsite.com/vacancies/index.html,但我想找到更流畅的解决方案。提前致谢
此错误主要是由app.yaml文件中的问题引起的,如果静态文件处理程序重定向到不存在的文件或提到的文件名不正确,则可能导致此错误。请确保您使用的是语言的更新版本并且文件中提到的名称是正确的。
您可以参考 public Documentation where reference for the App.yaml file is provided, you can also refer to the Whosebug answers for the and ,其中为静态网站提供了 app.yaml 处理程序配置的简要说明。
我的案例的解决方案:
- url: /(.*)\/$
static_files: public//index.html
upload: public/.*index.html
- url: /(.*)$
static_files: public//index.html
upload: public/.*/index.html
我的 React 应用程序已经 运行 在 GCP 引擎上。导航和所有页面看起来都很好,但直接链接会导致问题 - 例如,如果我打开我的网站。com/vacancies,我会收到错误日志,指出 未找到处理程序引用的静态文件: public/vacancies//index.html。 这是我的 app.yaml 处理程序配置:
handlers:
- url: /
static_files: public/index.html
upload: public/index.html
- url: /((.*\/)*[^\/]+\.[^\/]+)$
static_files: public/
upload: public/.*
- url: /(.*)$
static_files: public//index.html
upload: public/.*/index.html
解决方法是像这样打开页面 myWebsite.com/vacancies/index.html,但我想找到更流畅的解决方案。提前致谢
此错误主要是由app.yaml文件中的问题引起的,如果静态文件处理程序重定向到不存在的文件或提到的文件名不正确,则可能导致此错误。请确保您使用的是语言的更新版本并且文件中提到的名称是正确的。
您可以参考 public Documentation where reference for the App.yaml file is provided, you can also refer to the Whosebug answers for the
我的案例的解决方案:
- url: /(.*)\/$
static_files: public//index.html
upload: public/.*index.html
- url: /(.*)$
static_files: public//index.html
upload: public/.*/index.html