javascript - Node.js 服务器在 cloud9 中返回 html 文件而不是 json 响应

标签 javascript angularjs node.js cloud9-ide

我尝试在 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/

相关文章:

给定两个函数的Javascript找到交集

html - 如何创建外观独特的 Angular ui Bootstrap 对话框

javascript - UI Router - 嵌套 View 有双斜杠并重定向到根

javascript - 无法在 JavaScript 循环中从数据库获取数据

python - 使用 node.js pm2 在虚拟环境中运行 python 脚本

javascript - Sequelize 中是一对一还是多对一?

javascript - Ext.menu.Menu(上下文菜单)仅在右键单击时显示一次 - Ext JS 4.2.1

javascript - 如何使用 jQuery 或 JavaScript 清除 &lt;input type ='file'/> 中的文件

javascript - 拼接方法在子节点上下文中的奇怪行为

javascript - 查找数组中的属性并获取索引