【发布时间】:2020-08-22 18:21:03
【问题描述】:
希望有人能帮帮我!
我有一个已部署到 Google App Engine 的 Angular Universal 应用程序。
我有一个在 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
这是我的 app.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");
}
如果有人需要更多信息,请告诉我。请检查您是否发现有问题。
【问题讨论】:
标签: node.js angular angular-universal