ExpressRoute is a service that enables you to create private connections between Azure datacenters and infrastructure that's on your premises or in a colocation environment.
Questions tagged [express-router]
265 questions
0
votes
1 answer
How to response a html file from external express Router file
How can i render from outside any html documents wit express.router().
My app.js:
const express = require("express");
const fs = require("fs");
const https = require("https");
const path = require("path");
const app = express();
const https_port =…

coldstone
- 17
- 5
0
votes
0 answers
Why throwing an exception from an asynchronous handler in Express 5 doesn't pass the exception to the "next" handler?
According to Express 5 documentation, route handlers and middleware that return a Promise will call next(value) automatically when they reject or throw an error. I've been trying to use this for the past few hours, but I don't know what I'm doing…

Mehdi
- 137
- 1
- 8
0
votes
0 answers
Express.js app working perfectly on local machine, but produces 404 when app.post() fires on Netlify
I'd like a user to be directed to a specific page (promo1.html, promo2.html, etc...) when a corresponding promo code is entered into the form field. This runs nicely when I use it on localhost: but after deploying to Netlify it gives me a 404 when I…

Jake Flowers
- 1
- 1
0
votes
1 answer
Can't use exported module for express router as middleware
I'm trying to separate out the routes from the server file, however I can't seem to get my route controller to export whether I try to use require('') or import as syntax for the module export
My server.ts file
import express from 'express';
import…

BobbyBorn2L8
- 301
- 1
- 2
- 9
0
votes
1 answer
How to use http-proxy-middleware with express router in Nodejs
I am trying to use http-proxy-middleware in NodeJs. It is not working. I am working on node version 18.
const express = require('express');
const router = express.Router();
const { createProxyMiddleware } = require('http-proxy-middleware');
const…

user16968394
- 1
- 2
0
votes
0 answers
Whenever I send request to "/" this route my app ignores all my routes and only shows the root
I am creating an Api but all my routes gets ignored as soon as I add
app.use("/", (req, res, next) => {
res.redirect("https://documenter.getpostman.com/view/23982070/2s93RNwtyM");
});
The complete structure of the code is
app.use("/", (req, res,…

Hayder Ali
- 31
- 6
0
votes
1 answer
Apply middleware to one of two routers
I have an express app with two routers, one of which I want to be protected with a middleware that verifies an app key, and another one that is "public"
However, when I try to add the middleware, it seems to apply to both routers or in other words,…

Jacobo Koenig
- 11,728
- 9
- 40
- 75
0
votes
0 answers
Unable to access a specific route in my express server
I am new to Web Development & have started building a MERN app as a side project. I am encountering the below problem.
When I am trying to access a route in my routes file, I was unable to access it. It is showing this error in Postman when trying…

Modern Mahrshi
- 1
- 2
0
votes
1 answer
Express.js issues Router not working with phusion passenger Node.js
I have problems with Phusion Passenger and Express.js the router does not work and does not give me any kind of error
Try on a hosting with Node versions 16 and 14, as well as on a dedicated server with Node 16 (Cent OS)
Express version is:…

Jimmy Tools
- 3
- 1
0
votes
2 answers
how to solve Error : Cannot find module './routes/products' while using router on express js
this is products.js code path => (./routes/products.js)
let express = require('express');
let router = express.Router();
router.use('/', (req,res)=>{
res.send('I am product');
});
module.exports = router;
this is users.js code path =>…

Abrham_m
- 19
- 2
0
votes
3 answers
Is there a way to apply middlewares on all of specific request method?
I have been working on a typescript project. I have created a middleware to check users' subscription and do not want to let users access PUT and POST routes. But I still want them to be able to access GET and DELETE requests.
I know that the…

Saurav Ghimire
- 500
- 2
- 9
0
votes
0 answers
In express I have to add an route so that /login or /logingin takes me to the same page
router.post('/login',(req,res)=>{
res.redirect('/login')
})
this can simply redirect us to the login page when we type /login
if I type /looooooogin or /lo31232145gin or any other random words between lo and gin ,how can I still be redirected to…

shyam prakash
- 1
- 1
0
votes
1 answer
Express route in different file is accessible using prefix of different file
I have nodejs server file
server.js
const express = require('express');
const session = require('express-session');
const router = express.Router();
const https = require('https');
const app = express();
const api1 = require('./apps/routes/api1')(…

kuldeep gupta
- 55
- 1
- 7
0
votes
1 answer
Middleware in router showing req.body empty, however in actual data does exist in post request
I am trying to access req.body in express middleware in a router, however it is consoling empty req.body. However in actual data does exist. I am already using body-parser at app level but it is not working for me. Below is my code, I am trying to…

Nasir
- 23
- 4
0
votes
2 answers
can't export routes in express with ES6
I was writing the backend for my project. I have noticed that it was getting really messy and was repeating a lot of code over and over again. I decided to re-write everything and use classes. I also took the decision to use ES6 modules for…

DMantas
- 125
- 2
- 10