[英]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.