Questions tagged [node.js-connect]

Connect is a middleware framework for Node.js. It processes or decorates HTTP requests and responses to provide features such as session handling, authentication, asset management or compression.

298 questions
123
votes
5 answers

nodejs connect error: "has no method 'static'"

A newbie with NodeJs. I am trying to follow AngularJS pro and got stuck with setting up NodeJs server. According to book, I installed nodejs and then installed connect package using npm install connect. Then downloaded angularjs in folder next to…
Sheraz
  • 2,177
  • 4
  • 18
  • 21
97
votes
7 answers

How can I easily get access to form data in Express js?

I have a POST request with very simple and small amount of form data. How can I most easily access it? Many tutorials/posts etc talk about bodyParser, but this is no longer bundled with Express. Other places (blogs etc) recommend using urlencoded…
Dave Pile
  • 5,559
  • 3
  • 34
  • 49
76
votes
7 answers

Is it possible to set a base URL for NodeJS app?

I want to be able to host multiple NodeJS apps under the same domain, without using sub-domains (like google.com/reader instead of images.google.com). The problem is that I'm always typing the first part of the url e.g. "/reader" in…
David Tang
  • 92,262
  • 30
  • 167
  • 149
75
votes
3 answers

How to get rid of Connect 3.0 deprecation alert?

I'm a node.js developer who creates web apps using express.js. By now, my problem is: Whenever I create an app on my computer, npm install its stuff and run it (with node app.js and nodemon) I get this message in the console: connect.multipart()…
Amet Alvirde
  • 1,453
  • 3
  • 13
  • 22
72
votes
3 answers

Node.js EMFILE error with increasing traffic

I have very recently received a lot of traffic to my site that runs Node.js. With the increasing traffic it has started to crash a lot, which has not happened before. I get the following error in my log: { [Error: connect EMFILE] code: 'EMFILE',…
codekick
  • 723
  • 1
  • 5
  • 4
63
votes
7 answers

How to disable Express BodyParser for file uploads (Node.js)

I'm using Node.js + Express to build a web application, and I find the connect BodyParser that express exposes to be very useful in most cases. However, I would like to have more granular access to multipart form-data POSTS as they come - I need to…
Myk
  • 6,205
  • 4
  • 26
  • 33
62
votes
13 answers

"Cannot GET /" with Connect on Node.js

I'm trying to start serving some static web pages using connect like this: var connect = require("connect"); var nowjs = require("now"); var io = require("socket.io"); var app = connect.createServer( connect.static(__dirname +…
Nathan Campos
  • 28,769
  • 59
  • 194
  • 300
55
votes
12 answers

Node.js connect only works on localhost

I have written a small Node.js app, using connect, that serves up a web page, then sends it regular updates. It also accepts and logs user observations to a disk file. It works fine as long as I am on localhost, but I can't get other computers on…
schaz
  • 875
  • 2
  • 9
  • 12
51
votes
2 answers

What is the difference between 'session' and 'cookieSession' middleware in Connect/Express?

There are two session-related middleware packages bundled with Connect/Express. What is the difference? How do I choose? I'm assuming that session middleware is the same as cookieSession middleware - but with an extra store mechanism.
gfaceless
  • 1,529
  • 1
  • 17
  • 22
50
votes
8 answers

How to force parse request body as plain text instead of json in Express?

I am using nodejs + Express (v3) like this: app.use(express.bodyParser()); app.route('/some/route', function(req, res) { var text = req.body; // I expect text to be a string but it is a JSON }); I checked the request headers and the content-type…
pathikrit
  • 32,469
  • 37
  • 142
  • 221
49
votes
1 answer

What properties does Node.js express's Error object expose?

I would like to know what are the functions that the Error object of nodejs express exposes for use in error handling? A console.log of an error call new Error('NotFound') is showing only [Error: NotFound]. Is this because the .toString() method is…
shahalpk
  • 3,383
  • 7
  • 36
  • 55
43
votes
10 answers

node.js Error: connect ECONNREFUSED; response from server

I have a problem with this little program: var http = require("http"); var request = http.request({ hostname: "localhost", port: 8000, path: "/", method: "GET" }, function(response) { var statusCode = response.statusCode; var…
Marco Ghieri
  • 439
  • 1
  • 4
  • 3
41
votes
4 answers

Node.js : How to do something on all HTTP requests in Express?

I would like to do something like: app.On_All_Incoming_Request(function(req, res){ console.log('request received from a client.'); }); The current app.all() requires a path, and if I give for example this / then it only works when I'm on the…
Adam Halasz
  • 57,421
  • 66
  • 149
  • 213
40
votes
2 answers

How do I output Connect/Express's logger output to Winston?

I'm making a Node.js app and I am using Winston for most of my logging purposes. I also aware of the Connect/Express logger function and know it has a stream option... Is it at all possible to output the stuff from Connect/Express's logger function…
littlejim84
  • 9,071
  • 15
  • 54
  • 77
36
votes
5 answers

Connect or Express middleware to modify the response.body

I would like to have a middleware function which modifies the response body. This is for an express server. Something like: function modify(req, res, next){ res.on('send', function(){ res.body = res.body + "modified" }); …
The Who
  • 6,552
  • 5
  • 36
  • 33
1
2 3
19 20