Category "express"

multer file upload - how to get a value from multer in route?

I'm uploading a file using multer with Express. I'd like access a value from multer's storage object inside the route. How can I do that? Multer configuration (

Req.Params.Token returns undefined

In my code, I have my registration page send out a verification email once the form is filled out and submitted. They receive the link to their email to verify

Node.js get image from web and encode with base64

I'm trying to fetch an image from the web and encode it with base64. what i have so far is basically: var request = require('request'); var BufferList = requi

What is NODE_ENV and how to use it in Express?

This is my app that I'm currently running on production. var app = express(); app.set('views',settings.c.WEB_PATH + '/public/templates'); app.set('view engine',

jwt.verify not throwing error for expired tokens

I'm using JWT - jsonwebtokens in Nodejs. I'm creating a token and want to throw an error if the token expires. My token is created successfully and I'm checking

JSON.parse() Returning Unexpected end of input

[`const express = require('express'); const app = express(); const https = require('https'); const url = "https://api.thevirustracker.com/free-api?countryTimeli

StripeInvalidRequestError: You can only create new accounts if you've signed up for Connect

When trying to test Stripe Connect Api, I get the following error: 'StripeInvalidRequestError: You can only create new accounts if you've signed up for Connect

req.cookies returns undefined but cookies are set

I am using cookie-parser in my express app. When the root page is requested I set a random number on the cookie using res.cookie(name, value) and it sets it fin

Cannot get external images in NextJS with Custom server Express

I'm developing NextJS app with custom server by ExpressJS, and the app cannot show external image, code example: export function DocumentSection({content}) {

req.flash() not working after req.session.destroy()

Based on a condition, I need to destroy user's current session, and redirect him to a login page with a message. I use flash to have a show-once-only message. E

Use specific middleware in Express for all paths except a specific one

I am using the Express framework in node.js with some middleware functions: var app = express.createServer(options); app.use(User.checkUser); I can use the .

How to sign a cookie manually using cookieParser?

For the sake of testing, I need to provide a signed cookie with HTTP request. So that, my Express app server can consider it as a signed cookie and put it into

ExpressJs is return error `ERR_MODULE_NOT_FOUND` if I import the file without `js` extension

I build a expressJs app by ES6 and I got the below error: (node:4132) ExperimentalWarning: The ESM module loader is experimental. internal/modules/run_main.js:

app.get - is there any difference between res.send vs return res.send

I am new to node and express. I have seen app.get and app.post examples using both "res.send" and "return res.send". Are these the same? var express = require

How to disable Morgan (request logger) during unit test?

I use Morgan (default express generator request logger), and I'm trying to disable it during unit testing. Currently I'm using the default configuration, which

CORS issues: The 'Access-Control-Allow-Origin' header mustn't contain multiple values

I want to allow my server to let two different domains read data without getting a CORS issue. Therefore, I wrote the following code line (in node.js): app.

Difference between req.url and req.originalUrl in Express.js version 4

I am trying to implement login feature in Express.js version 4 app. I need to determine whether an user is logged in before he can do certain actions. So I have

How do I move files in node.js?

How can I move files (like mv command shell) on node.js? Is there any method for that or should I read a file, write to a new file and remove older file?

NextJS: How to handle multiple dynamic routes at the root

Goal: I would like to achieve github style routing, where abcd in github.com/abcd could resolve to a user profile page or a team page. I currently have a v

What does "trust proxy" actually do in express.js, and do I need to use it?

I am writing an express app that sits behind an nginx server. I was reading through express's documentation and it mentioned the 'trust proxy' setting. All it