Friday 7 April 2017

Why is my wildcard route firing even after the res is sent at the correct route above it?

A simplified version of my app and issue:const express = require('express') const app = express() const router = express.Router() app.use(router) router.get('/', function (req, res) { res.send('Hello!') }) router.get('/*', async function (req, res) { console.log("NO!!") }) If I go to http://localhost:7000 I get BOTH 'Hello' in the browser - indicating that the request has been routed and handled by my first route... but then I ALSO get 'NO!' in the log - indicating that multiple routes are responding to the same request. This is surprising, and not preferred behavior.

Submitted April 07, 2017 at 07:36PM by L000

No comments:

Post a Comment