[Bug] Express routes mounted through a barrel module lose their mount prefix

Open
#6,442 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Hung1510 is already working on this.

Since Nov 27, 2026.

  • #6469 by @Hung1510 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
express, javascript, python

Research direction

Start with _imported_router in packages/core/src/repowise/core/workspace/extractors/http/express.py and trace how mount keys are matched to router files. Read tests/unit/workspace/test_express_handed_routers.py and add coverage for a barrel export bound to require, keeping the direct-require case as a control. Done when the barrel-mounted route gets the /api/user prefix and an inline barrel keeps its current behavior.

Written by the indexing model from the issue text.

Description

bug help wanted

Summary

An Express mount of a member of a barrel module (routes/index.js doing module.exports = { user }) is keyed to the barrel, so the router file never gets the mount prefix and its routes are served at / instead of /api/user.

packages/core/src/repowise/core/workspace/extractors/http/express.py:196-210

spec, exported = imports[head]
...
return (spec, member.split(".")[0]) if exported == "default" else None

Mechanism

  • _imported_router turns routes.user into (./routes, user), so the mount key becomes routes/index:user.
  • Nothing follows module.exports = { user } (with user = require('./user')) to routes/user.js, so that file looks up its own key and finds no prefix.

Repro

LibreChat: app.use('/api/user', routes.user) leaves its 527 providers without an /api/... prefix. Minimal fixture on main:

server/index.js         const routes = require('./routes'); app.use('/api/user', routes.user);
server/routes/index.js  const user = require('./user'); module.exports = { user };
server/routes/user.js   router.get('/plugins', ...); module.exports = router;
provider http::GET::/plugins        (expected /api/user/plugins)

With app.use('/api/user', require('./routes/user')) the same file gives /api/user/plugins.

Impact

Prefix-less providers link to the wrong callers, which is where the wrong links on LibreChat come from.

Done looks like

  • When the barrel exports { name } bound to a require, mount under the required file.
  • A barrel that defines the router inline keeps today's behaviour.

Tests

tests/unit/workspace/test_express_handed_routers.py: the barrel case plus the direct-require control.

Dominant language
Python
Stars
7.1k
Forks
756
Avg merge
21h 5m
Merged PRs (30d)
797

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from repowise-dev/repowise

All issues in repowise-dev/repowise

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.