iisnode和快递 [英] iisnode and express

查看:126
本文介绍了iisnode和快递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定这个问题已被问过一百万次,但我还没有找到解决以下问题的方法。

I'm sure this question has been asked a million times but I've not found any solution to the following problem as of yet.

我有一个使用nodejs和express运行的基本应用程序。当我在节点中运行应用程序时,它默认将我发送到我公共文件夹中的index.html。即使我没有设置任何路线。我希望这种情况发生。

I have a basic application running using nodejs and express. When I run the application in node, it by default sends me to the index.html in my public folder. Even if I don't have any routes set up. I want this to happen.

我已经安装了iisnode并在'Default Website'下创建了一个名为'Devices'的新应用程序。我把我的申请保持不变。阅读我需要用web.config排序一些东西,并决定使用这里提到的配置(不是yaml):

I've installed iisnode and created a new application under 'Default Website' called 'Devices'. I put my application in there unchanged. Reading around I needed to sort some stuff out with the web.config and decided to go with the config mentioned here (not the yaml):

http://tomasz.janczuk.org/2012/05/yaml-configuration-support-in-iisnode。 html

当我尝试在我的浏览器中加载应用程序时,它总是试图在我的app.js中找到路径并向我发回消息as:

When I try and load the app up in my browser it always tries to find the route in my app.js and throws messages back at me such as:

无法获取/设备/

我真的用这个来拔我的头发并且不要不知道该怎么办!我是否必须在app.js入口点内为静态内容设置默认路由?我有以下内容:

I'm really pulling my hair out with this one and don't know what to do! Do I have to set up a default route for static content inside of my app.js entry point? I have the following in place:

app.configure(function(){
  app.set('port', process.env.PORT || 3000);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.favicon());
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(app.router);
  app.use(express.static(path.join(__dirname, 'public')));
});

但是当我从root用户加载应用程序时,它仍然没有把我交给index.html :

But it still doesn't hand me over to index.html when I load the application from it's root:

'http:// localhost / devices /'

'http://localhost/devices/'

任何人都可以帮我解决这个问题吗?

Anyone able to help me out with this?

推荐答案

可以在以下网址找到一个好的建议: iisnode托管的Web应用程序可以计算出托管它的虚拟路径?基本上,您使用一个小变量来抽象路径和一个环境变量(如果存在)来控制它。另一个好的帖子(可能更好的解决方案)可以在 https://github.com/tjanczuk/找到iisnode / issues / 160

A good suggestion can be found at: Can an iisnode-hosted web application work out the virtual path at which it is hosted? Essentially, you use one small variable to abstract the path and an environment variable (if it exists) to control it. Another good post (possibly better solution) can be found at https://github.com/tjanczuk/iisnode/issues/160

这篇关于iisnode和快递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆