【问题标题】:Problem to deploy a node / express API using now.sh使用 now.sh 部署节点/快速 API 的问题
【发布时间】:2019-09-29 08:22:47
【问题描述】:

我正在尝试部署一个 node / express API,它有几个端点供 now.sh 使用。

我的问题是如何正确配置文件 now.json。

将图片保留在您可以看到项目完整结构的位置,主路径将是 ./src/ 所有文件夹和文件。

主入口点是http://localhost:3000/api/v1/ 用于本地主机

我删除文件 now.json 并从终端粘贴now 命令,然后在以下路径中生成部署

https://ryuanime.chrismichael.now.sh

但是当我尝试转到https://ryuanime.chrismichael.now.sh/api/v1 时,它会显示404: NOT_FOUND

图片

source code

now.json

{
  "version": 2,
  "name": "ryuanime",
  "builds": [
    {
      "src": "src/index.ts",
      "use": "@now/node-server"
    }
  ],
  "routes": [{"src": "/(.*)", "dest": "/src/index.ts"}]
}

【问题讨论】:

    标签: node.js typescript express deployment


    【解决方案1】:

    由于某种原因,它通过引用来起作用

    "src": "./src/index.ts"
    

    而不是

    "src": "src / index.ts",
    
    {
      "name": "ryuanime-api",
      "version": 2,
      "builds": [
        {
          "src": "./src/index.ts",
          "use": "@now/node-server"
        }
      ],
      "routes": [
        { "src": "/(.*)", "dest": "/src/index.ts" }
      ]
    }
    

    【讨论】:

      猜你喜欢
      • 2019-04-30
      • 1970-01-01
      • 1970-01-01
      • 2018-10-31
      • 1970-01-01
      • 2019-07-31
      • 2020-11-22
      • 1970-01-01
      • 2021-07-19
      相关资源
      最近更新 更多