[英]How do I run an Angular Universal app and separate node app for backend api on Google App Engine?
我希望有人可以幫助我!
我有一個已部署到 Google App Engine 的 Angular 通用應用程序。
我有一個在 GAE 的默認實例上運行的應用程序,它有自己配置的自定義域。
所以現在我想運行一個單獨的節點應用程序,它基本上只是一個帶有郵件 api 端點(/api/sendmail)的快遞服務器來發送郵件。
此端點將在 http://localhost:3000/api/sendmail 上運行。 以下是我所有的文件。
當我點擊端點/api/sendmail
並使用 gcloud app logs tail -s servicename 檢查日志時,它會注銷app.listen(3000, () => { console.log("The server started on port 3000");});
.
但它似乎沒有運行以下。 它不運行控制台日志?
app.post("/api/sendmail", (req, res) => {
console.log("Got Request");
}
我的 package.json 有這些腳本
"start": "node dist/server",
"deploy": "ng build --prod && npm run build:ssr && gcloud app deploy --quiet && gcloud app deploy dispatch.yaml --quiet",
Proxy.conf.json 文件有這個
{
"/api": {
"target": "http://localhost:3000",
"secure": false,
"logLevel": "debug",
"pathRewrite": {
"^/api": ""
}
}
}
App.yaml
runtime: nodejs10
handlers:
- url: /.*
secure: always
redirect_http_response_code: 301
script: auto
dispatch.yaml
dispatch:
- url: "*/api/*"
service: lunr-app-backend
這是我的應用程序。yaml 在自己的服務上運行節點應用程序
runtime: nodejs10
service: servicename
handlers:
- url: /api/.*
secure: always
redirect_http_response_code: 301
script: auto
我的節點應用程序有一個文件:nodemailer.js
app.listen(3000, () => {
console.log("The server started on port 3000");
});
app.post("/api/sendmail", (req, res) => {
console.log("Got Request");
}
如果有人需要更多信息,請告訴我。 請檢查您是否發現有問題。
我看到您在 Angular 應用程序中使用了 SSR。 我認為您需要修改 server.ts 文件。 請檢查以下代碼以獲取示例:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.