我尝试在 c9.io 中开发 - 复制项目的结构:
\-C9ProjectName
|
+---Frontend
| |
| \---index.html - AngularJS app
|
\---Backend
|
\---server.js - Node.js server
Server.js 在 env.IP 和 env.PORT 上启动,并通过 https 使用 Express。 Index.html 通过 $http.get(' https://C9ProjectName.c9.io/api/method ') 获取请求,但响应 html 文件:
<title>Sign-in | Cloud9 IDE - Ajax.org</title>
<meta name="description" content="Meet Cloud9, development-as-a-service for Javascripters and other developers"/>
如果调用 ' https://C9ProjectName.c9.io/api/method ' 直接 - 服务器发送带有正常 JSON 答案的响应。
什么会导致从 Cloud 9 返回 html 文件?
最佳答案
您的工作空间似乎是私有(private)的。如果您尝试通过代码访问工作区,则需要公开您的应用程序 URL。您可以通过单击 IDE 右上角附近的“共享”,然后选中“应用程序”url 旁边的“公共(public)”来完成此操作。
关于javascript - Node.js 服务器在 cloud9 中返回 html 文件而不是 json 响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32381456/