![](/img/trans.png)
[英]How to set a different NODE_ENV for my master and develop Git branches in my Google App Engine app.yaml file?
[英]How to configure app.yaml file for node react project in google app engine
我正在使用react js和nodejs開發應用程序,當我在本地計算機上運行該應用程序時,它可以正常工作
localhost:3000/AboutUs
localhost:3000
當我刷新上述URL時,它將顯示正確的網頁。 我在Google App Engine中部署了此應用程序,當刷新以下頁面時,它表明未找到請求的URL。 有人能讓我知道原因嗎?
www.mydomain.com/AboutUs
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
這是因為您沒有定義的處理程序來定向/AboutUs
URL。 您可以在handlers
下添加:
- url: /AboutUs
script: auto
或在網址列表的末尾添加通配符處理程序,例如:
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
將通配符處理程序/.*
保留在末尾很重要,因為否則所有URL都將落入該通配符處理程序,並且它將不使用其他URL處理程序。
另外, script
還缺少兩個空格, static_files
和url下的upload
標簽,我不知道是否是因為將app.yaml
內容復制到答案時的格式,但是無論哪種方式, 縮進在YAML中都很重要文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.