简体   繁体   English

如何在Google App Engine中为节点反应项目配置app.yaml文件

[英]How to configure app.yaml file for node react project in google app engine

I'm developing an application using react js and nodejs.When I run the application in local machine it works properly as a example 我正在使用react js和nodejs开发应用程序,当我在本地计算机上运行该应用程序时,它可以正常工作

localhost:3000/AboutUs
localhost:3000

When I refresh the above URLs, it shows the correct web page. 当我刷新上述URL时,它将显示正确的网页。 I deploy this application in Google App Engine and when I refresh the below page it shows that the requested URL was not found. 我在Google App Engine中部署了此应用程序,当刷新以下页面时,它表明未找到请求的URL。 Can any one let me know the reason for this? 有人能让我知道原因吗?

www.mydomain.com/AboutUs

app.yaml code is as below app.yaml代码如下

runtime: nodejs8
handlers:
- url: /api/.*
# secure: always
# redirect_http_response_code: 301
script: auto
- url: /
static_files: build/index.html
upload: build/index.html

It's because you don't have a defined handler to direct your /AboutUs URL. 这是因为您没有定义的处理程序来定向/AboutUs URL。 You can either add, under handlers : 您可以在handlers下添加:

- url: /AboutUs
  script: auto

Or add a wildcard handler at the end of the url list, for example: 或在网址列表的末尾添加通配符处理程序,例如:

runtime: nodejs8
handlers:
- url: /api/.*
# secure: always
# redirect_http_response_code: 301
  script: auto
- url: /
  static_files: build/index.html
  upload: build/index.html
- url: /.*
  script: auto

It's important to keep the wildcard handler /.* at the end, since otherwise all the URL's will fall under it, and it won't use the other url handlers. 将通配符处理程序/.*保留在末尾很重要,因为否则所有URL都将落入该通配符处理程序,并且它将不使用其他URL处理程序。

Also you had two spaces missing in the script , static_files and upload tags under the url's, I don't know if it was because of the formatting when copying the app.yaml contents to your answer, but either way, indentation is important in YAML files. 另外, script还缺少两个空格, static_files和url下的upload标签,我不知道是否是因为将app.yaml内容复制到答案时的格式,但是无论哪种方式, 缩进在YAML中都很重要文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在我的Google App Engine app.yaml文件中为我的母版设置不同的NODE_ENV并开发Git分支? - How to set a different NODE_ENV for my master and develop Git branches in my Google App Engine app.yaml file? 为 Node.js 和 React.js 部署到 App Engine 设置 app.yaml 文件 - Setting up app.yaml file for Node.js and React.js deployment to App Engine 如何使用 app.yaml 文件为 App Engine / Node.js 应用程序运行本地服务器? - How do I run a local server for an App Engine / Node.js app with an app.yaml file? Google App Engine Node.js应用程序 - “解析app.yaml时出错:未知的网址处理程序类型” - Google App Engine Node.js App - “Error parsing app.yaml: Unknown url handler type” Google App Engine - 使用相同的 app.yaml 部署不同的文件夹 - Google App Engine - Deploy different folder with the same app.yaml Google App Engine CORS“解析./app.yaml时出错:未知的网址处理程序类型” - Google App Engine CORS “Error parsing ./app.yaml: Unknown url handler type” GCP:根据 dispatch.yaml 规则配置 app.yaml - GCP: Configure app.yaml based on dispatch.yaml rules 如何使用 JS 和 NodeJS 服务器为标准 html 页面正确配置 app.yaml? - How to correctly configure app.yaml for a standard html page with JS and NodeJS server? 如何将app.yaml中的google-cloud-auth.json安全保存为环境变量? - How to keep google-cloud-auth.json securely in app.yaml as an environmental variable? 如何正确指定 app.yaml 中的缩放设置? - How can I specify scaling settings in app.yaml correctly?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM