Questions tagged [express]

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

Express.js 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.js is expressjs.com. The source can be found on GitHub.

Useful links:

Older versions

94248 questions
16
votes
3 answers

getting RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined in express app

I am getting the above error when running the following code in my express app. When I go to localhost:3000/cards. This is in my cards.js file. const express = require('express'); const router = express.Router(); const { data } =…
AltBrian
  • 2,392
  • 9
  • 29
  • 58
16
votes
4 answers

NestJS - request timeout

How to set timeout for all requests and if timedout then respond with custom json? I tried to use: import * as timeout from 'connect-timeout'; import { NestFactory } from '@nestjs/core'; import { ApplicationModule } from './app.module'; const port…
user2334711
  • 171
  • 1
  • 1
  • 3
16
votes
3 answers

Handlebars - Expecting 'OPEN_INVERSE_CHAIN', 'INVERSE', 'OPEN_ENDBLOCK', got 'EOF'

I am trying out handlebars and I am using the following simple template for this:

{{title}}

{{body}}

{{#each list}}
  • {{@index}}. {{this}}

Carol.Kar
  • 4,581
  • 36
  • 131
  • 264
16
votes
1 answer

How and when do I generate a Node/Express cookie secret?

I'm building a node/express app and am using the express-session and mongo-connect modules to store my sessions and persist them on restart. However, a new cookie ID is still generated every time I restart the server. I've narrowed the problem down…
Max Pekarsky
  • 590
  • 2
  • 6
  • 20
16
votes
2 answers

Why does the browser send an OPTIONS request even though my frontend code is just making a POST request?

My front-end code:
{ this.searchInput = input; }}/>
// search method: const baseUrl = 'http://localhost:8000/'; // where the…
Li Enze
  • 679
  • 2
  • 5
  • 18
16
votes
3 answers

NodeJs application behind Amazon ELB throws 502

We have a node application running behind Amazon Elastic Load Balancer (ELB), which randomly throws 502 errors when there are multiple concurrent requests and when each request takes time to process. Initially, we tried to increase the idle timeout…
RAGHU RAMAN
  • 537
  • 4
  • 16
16
votes
5 answers

Error: Could not execute GraphicsMagick/ImageMagick: identify "-ping" "-format" "%wx%h"

I'm trying to find the dimensions of the images in a production machine.It returns error. Could not execute GraphicsMagick/ImageMagick: identify "-ping" "-format" "%wx%h" "uploads/userPhoto-1499669685192.png" this most likely means the gm/convert…
akash gaur
  • 303
  • 1
  • 3
  • 9
16
votes
1 answer

vue-router and Express

I've build a simple app using Vue.js and their vue-cli webpack. I've used vue-router to control navigation around the site with the different views. This works fine when running locally. I'm now wanting to deploy this onto Heroku, however the urls…
James Clare
  • 553
  • 1
  • 4
  • 11
16
votes
4 answers

Nodejs express, Heroku CORS

The server side of my app was built using Node with express, It was working fine locally, but now I've uploaded to Heroku I'm getting CORS errors, even though I've handled it within the app index.js var express = require('express'); var bodyParser =…
RasMason
  • 1,968
  • 4
  • 32
  • 54
16
votes
1 answer

How can I handle type with middleware of express?

I am using Typescript in Node.js. When you use Express middleware, you often transform the Request object. With Typescript, however, we could not track how the Request object was transformed. If you know the middleware that passed before, is there a…
Yoshi
  • 161
  • 1
  • 4
16
votes
1 answer

Replacing fs.readFile with fs.createReadStream in Node.js

I have code for reading an image from directory and sending it to index.html. I am trying to replace fs.readFile with fs.createReadStream but i have no idea how to implement this as i can not find a good example. Here is what i got (index.js) var…
AESTHETICS
  • 989
  • 2
  • 14
  • 32
16
votes
1 answer

Amazon Alexa, alexa-app and middleware

have been going different routes for 2 days now and can't figure it out. Perhaps someone can shed some light on my problems. I am trying to run a botserver that connects to multiple plaforms and already have around 5 working. I am now also trying…
lleto
  • 674
  • 2
  • 7
  • 25
16
votes
4 answers

How to set port for express server dynamically?

This is the question mostly asked by the beginners, as I had this question when I was starting out How to set port for express without needing to hardcode or even choose port yourself? This is the question I had when I was starting out in node and…
Syed Huzaifa Hassan
  • 776
  • 1
  • 6
  • 22
16
votes
3 answers

Express.js Cannot read property 'req' of undefined

My Express.js app has been throwing Cannot read property 'req' of undefined. In essence, it listens for a GET request, grab the content query, and then reply with a table. Here's the parts that present the problem. index.js var panels =…
starleaf1
  • 2,701
  • 6
  • 37
  • 66
16
votes
2 answers

How to register custom Handlebars helpers?

After a long search I still can't seem to find much information on where to put my custom handlebars helpers. Do I put them in a