Questions tagged [express-router]

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.

185 questions
1
vote
1 answer

Syntax error: Illegal Break Statement on using next in middleware to pass to other middleware

I am trying to use a middleware to verify my user token. The problems come when I am trying to use next() to move on to the next middle were. What I think is that somehow my next() is not working as it should. Please help. Middleware code: async…
1
vote
1 answer

Static CSS file not working with router Express

I am using express to build a simple login app. I am using ejs as my template engine.the file structure of my application is package.json server.js routes index.js users.js views layouts.ejs login.ejs register.ejs …
Nisha Dave
  • 227
  • 1
  • 8
1
vote
2 answers

How can I route all calls starting with string api to their handlers in an express middleware

I have a express app.js with typical app.get('/path1', (req, res => {}) app.get('/path2', (req, res => {}) app.get('/path3', (req, res => {}) now I want to catch all routes, starting with api such as below and redirect them to their…
nightograph
  • 1,810
  • 2
  • 27
  • 43
1
vote
1 answer

Why Postman gives me "Not Found 404" error?

When I send a GET request to the https://localhost:3443/images/ endpoint I get this result: [ { "_id": "5e8ef5fa98c70f30a8986070", "createdAt": "2020-04-09T10:16:26.796Z", "updatedAt": "2020-04-09T10:16:26.796Z", …
user3486308
  • 1,776
  • 3
  • 25
  • 51
1
vote
0 answers

Swagger NodeJS stub + Existing

Hello there community! I have the following scenario: Existing Node + Express app. Existing routes in place. Integrating the auto-generated Node stub for my API. I have modified the startup code to merge it with my existing Express app: //…
1
vote
1 answer

Having issues pulling data from my database and populating it (ById) onto the my Vue view (using Axios). Backend is Node/Express

I know by the console that the route is pointing it to the correct Id number, but it's throwing a 404 and I'm not sure where the connection is going bad. PrizesById is essentially a duplicate of another route holding data called Prizes. I wasn't…
user12913705
1
vote
0 answers

How to define a route with route params separated with a colon in Express?

The route I'm trying to make looks something similar to this: /config/param1:param2:param3/ Considering param1|2|3 are all route params the route definition should look like /config/:param1::param2::param3/ which works good until the request is…
lolbas
  • 796
  • 1
  • 8
  • 31
1
vote
0 answers

Split router logic into separate functions

I have a get request handler of a Router in Node.js and it has a lot of code: const express = require("express"); const router = express.Router(); router.get("/api/employees/employee-response", async (req, res) => { try { // First action…
JAN
  • 18,509
  • 49
  • 147
  • 268
1
vote
1 answer

Express router calls the wrong route

So, I have an API with with a few routes defined (I'm not going to list all of them) where one of them never gets called unless I change it's name. this is how I define them in code: // Each middleware/function is separated by commas…
1
vote
2 answers

how to fix session variable not defined in route (auth.js) while it is working fine in app.js

I am setting up a new server in the nodeJs. where Do I need to set session such that I can access session in route files?
Gaurav Gupta
  • 11
  • 1
  • 2
1
vote
0 answers

Why is axios POST is called twice?

My react app uses axios for POST-requests to the server. When the server needs more than 2min for answering the request is called again. But only in FF, Chrome, NOT in IE11. I don't think that this is a Cross-Origin Resource Sharing (CORS) preflight…
dev7005
  • 11
  • 3
1
vote
1 answer

Router is mishandling static file load

In developing my website I ran across an issue with the way that my static CSS, JS, and image files are being loaded to my site. Once I navigate past the .index file or any route tree, my static directory misloads and the route index suddenly is…
1
vote
2 answers

Unexpected error while routing a bad request call with Express

Consider the following Express code: router.get('/v1/api/book/:id', function (req, res) { if (!req.params.id) res.status(401).send('Missing book id'); res.status(200).send('Book found!'); }); By invoking…
SubZeno
  • 311
  • 3
  • 14
1
vote
1 answer

Express 4, matching req.path with URL param

I made a custom middleware for Express router that allows me to whitelist certain endpoints of my API to be excluded from authentication. However I have a route where I depend on URL parameter and I can't get my middleware to work as intended with…
MerkisL
  • 115
  • 2
  • 10
1
vote
1 answer

Express Router Middleware Called Multiple Times

Using Express and Express Router. I've got a handful of files in a single directory that all implement Express.Router. I'm dynamically requiring them, adding some middleware and then attached them to a "meta" router and finally calling…
seth
  • 79
  • 9
1 2
3
12 13