首页 > 解决方案 > 蒸汽构建失败

问题描述

Iam 目前是 Vapor Swift 服务器端的新手,最初我有两个查询

1)问题

蒸汽构建失败

错误:

构建失败。

2) 问题

运行时我得到 localhost:8080/Hello 这个 url 在 Safari 浏览器中工作正常

当谈到 Ios 应用程序时,我调用了我得到的 URl GET 方法

错误

获取 http:0.0.0.0:8080/Hello,HTTP 状态代码 503 时出错

如何在 Java、Javascript 等任何语言之外测试 Vapor Api

标签: apivaporswift4.1

解决方案


您需要将 Vapor 绑定到0.0.0.0127.0.0.1也可能在您的网络中工作)而不是localhost(默认):

public func configure(
    _ config: inout Config,
    _ env: inout Environment,
    _ services: inout Services
) throws {

    services.register(EngineServerConfig.default(hostname: "0.0.0.0"))
    ...
}

如果你要部署到 heroku/etc,你可以在你的 Procfile 中设置它:

web: Run serve -e production -b 0.0.0.0:$PORT

推荐阅读