Node.js 服务器 return html 文件而不是 json cloud9 中的响应

Node.js server return html file instead json response in cloud9

我尝试在 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 个文件带到 return?

您的工作区似乎是私人的。如果您尝试通过您的代码访问您的工作区,您将需要创建您的应用程序 URL public。您可以通过单击 IDE 右上角附近的 'Share' 然后选中 'Application' url.

旁边的 'Public' 来完成此操作