【问题标题】:Issue with running json-server on AWS server (returning 404)在 AWS 服务器上运行 json-server 的问题(返回 404)
【发布时间】:2018-11-03 15:06:09
【问题描述】:

我一直在我的本地主机上开发一个应用程序,我现在将它托管在 AWS 上。该应用程序使用 json-server 返回虚拟数据,它在我的笔记本电脑上运行良好。但是,我无法让它在我的 AWS 服务器上运行。在 AWS 服务器上,安装了 json-server 并按预期启动:-

json-server jsonserver.db.json --port 9001

Loading jsonserver.db.json
Done

Resources
http://localhost:9001/urlone

Home
http://localhost:9001

但它只从 get 请求中返回 404(在我的控制台中):-

http://localhost:9001/urlone/1 0 ()

但是,如果我在我的本地主机(我正在开发的笔记本电脑)上运行 json-server,则页面加载正常。所以很明显 GET 请求是植根于我自己的本地主机而不是服务器的。

无论如何我可以改变这个,以便服务器将获取请求发送到它自己的本地主机?

【问题讨论】:

    标签: amazon-web-services localhost json-server


    【解决方案1】:

    使用以下参数运行 JSON-Server:

    --host 'Private IPs'
    

    例如:

    json-server --host 172.31.88.188 --port 80 db.json
    

    这适用于我在 Ubuntu Server 上的 AWS 中。

    【讨论】:

    • 如果您使用Windows Server,您需要关闭Windows防火墙或设置规则。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-24
    • 1970-01-01
    • 1970-01-01
    • 2018-09-13
    • 2017-02-19
    • 1970-01-01
    相关资源
    最近更新 更多