Questions tagged [express]

Express is a minimal and flexible Node.js web application framework providing a robust set of features for building web applications.

Express is a minimal and flexible Node.js web application framework providing a robust set of features for building web applications.

The official website of Express is expressjs.com. The source can be found on GitHub.

Useful links:

Older versions

76920 questions
1811
votes
19 answers

Writing files in Node.js

I've been trying to find a way to write to a file when using Node.js, but with no success. How can I do that?
Gjorgji
  • 19,588
  • 8
  • 28
  • 38
1316
votes
23 answers

How to get GET (query string) variables in Express.js on Node.js?

Can we get the variables in the query string in Node.js just like we get them in $_GET in PHP? I know that in Node.js we can get the URL in the request. Is there a method to get the query string parameters?
XMen
  • 25,629
  • 39
  • 95
  • 148
884
votes
35 answers

Error: Can't set headers after they are sent to the client

I'm fairly new to Node.js and I am having some issues. I am using Node.js 4.10 and Express 2.4.3. When I try to access http://127.0.0.1:8888/auth/facebook, i'll be redirected to http://127.0.0.1:8888/auth/facebook_callback. I then received the…
DjangoRocks
  • 10,648
  • 7
  • 34
  • 51
864
votes
11 answers

npm WARN package.json: No repository field

I installed Express.js with the following command: sudo npm install -g express I get the following warnings: npm WARN package.json range-parser@0.0.4 No repository field. npm WARN package.json fresh@0.1.0 No repository field. npm WARN package.json…
JR Galia
  • 16,343
  • 19
  • 84
  • 143
830
votes
23 answers

How to access POST form fields

Here is my simple form:
murvinlai
  • 43,517
  • 50
  • 120
  • 169
694
votes
34 answers

Why doesn't adding CORS headers to an OPTIONS route allow browsers to access my API?

I am trying to support CORS in my Node.js application that uses the Express.js web framework. I have read a Google group discussion about how to handle this, and read a few articles about how CORS works. First, I did this (code is written in…
mikong
  • 7,600
  • 3
  • 13
  • 15
585
votes
24 answers

Error: request entity too large

I'm receiving the following error with express: Error: request entity too large at module.exports (/Users/michaeljames/Documents/Projects/Proj/mean/node_modules/express/node_modules/connect/node_modules/raw-body/index.js:16:15) at json…
mike james
  • 6,780
  • 3
  • 16
  • 20
580
votes
8 answers

How to access the GET parameters after "?" in Express?

I know how to get the params for queries like this: app.get('/sample/:id', routes.sample); In this case, I can use req.params.id to get the parameter (e.g. 2 in /sample/2). However, for url like /sample/2?color=red, how can I access the variable…
Hanfei Sun
  • 39,245
  • 33
  • 107
  • 208
557
votes
16 answers

How to get the full URL in Express?

Let's say my sample URL is http://example.com/one/two and I say I have the following route app.get('/one/two', function (req, res) { var url = req.url; } The value of url will be /one/two. How do I get the full URL in Express? For example, in…
Chris Abrams
  • 32,712
  • 19
  • 49
  • 56
555
votes
21 answers

ExpressJS How to structure an application?

I'm using the ExpressJS web framework for NodeJS. People using ExpressJS put their environments (development, production, test...), their routes etc on the app.js. I think that it's not a beautiful way because when you have a big application, app.js…
Sandro Munda
  • 36,427
  • 21
  • 94
  • 117
531
votes
11 answers

bodyParser is deprecated express 4

I am using express 4.0 and I'm aware that body parser has been taken out of the express core, I am using the recommended replacement, however I am getting body-parser deprecated bodyParser: use individual json/urlencoded middlewares…
Melbourne2991
  • 9,735
  • 10
  • 38
  • 79
524
votes
5 answers

Express.js - app.listen vs server.listen

This may be a very basic question but I simply don't get it. What is the difference between creating an app using Express.js and starting the app listening on port 1234, for example: var express = require('express'); var app =…
Tamas
  • 9,401
  • 11
  • 42
  • 76
505
votes
10 answers

Proper way to return JSON using node or Express

So, one can attempt to fetch the following JSON object: $ curl -i -X GET http://echo.jsontest.com/key/value/anotherKey/anotherValue HTTP/1.1 200 OK Access-Control-Allow-Origin: * Content-Type: application/json; charset=ISO-8859-1 Date: Wed, 30 Oct…
MightyMouse
  • 10,888
  • 7
  • 31
  • 41
498
votes
7 answers

Enabling HTTPS on express.js

I'm trying to get HTTPS working on express.js for node, and I can't figure it out. This is my app.js code. var express = require('express'); var fs = require('fs'); var privateKey = fs.readFileSync('sslcert/server.key'); var certificate =…
Alan
  • 42,055
  • 16
  • 107
  • 130
479
votes
9 answers

What is Express.js?

I am a learner in Node.js. What's Express.js? What's the purpose of it with Node.js? Why do we actually need Express.js? How is it useful for us to use with Node.js? What's Redis? Does it come with Express.js?
vinod
  • 7,782
  • 7
  • 26
  • 36
1
2 3
99 100