简体   繁体   English

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

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

I try to develop in c9.io - copied project with structure: 我尝试在c9.io中开发-复制具有结构的项目:

\-C9ProjectName
  |
  +---Frontend
  |   |
  |   \---index.html - AngularJS app
  |
  \---Backend
      |
      \---server.js - Node.js server

Server.js started on env.IP and env.PORT and use Express by https. Server.js在env.IP和env.PORT上启动,并通过https使用Express。 Index.html get request by $http.get(' https://C9ProjectName.c9.io/api/method ') but response html file: 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"/>

If call ' https://C9ProjectName.c9.io/api/method ' directly - server sends response with normal JSON answer. 如果直接调用“ https://C9ProjectName.c9.io/api/method”-服务器发送带有常规JSON答案的响应。

What brings to return of html file from Cloud 9? 是什么带来了Cloud 9中html文件的返回?

It seems your workspace is private. 您的工作区似乎是私有的。 If you're trying to access your workspace via your code, you will need to make your Application URL public. 如果您尝试通过代码访问工作区,则需要将应用程序URL公开。 You can do that by clicking on 'Share' near the top right of the IDE and then checking 'Public' next to the 'Application' url. 您可以通过单击IDE右上角附近的“共享”,然后选中“应用程序” URL旁边的“公共”来实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM