I have a server that is using Express to route requests.
In this I have the following route set up:
productRouter = ProductRouter app
app.use '/', productRouter
app.use '/products/(videocloud|perform)/*', productRouter
app.use '/user', UserRouter accountService: app.get('accountService'), setiClient: app.get('setiClient') # user endpoint for StudioModule client side SDK
The problem is that the route that is established to handle '/' requests is for some reason ahandling all requests that weren't rpreviously routed. meaning that if a user attempts to navigate to '/user' it get's handled by product router.
What is happening here, and what would the appropriate way to handle domain-level requests be?
app.use '/', productRouter
runs the middleware productRouter at any request that has the prefix of /
which would include all requests.
If you want to handle just the root domain request at /, use app.get
, for example:
app.get('/', function(req, res){
res.send('hello world');
});