-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
force leading slash with middleware #5336
Comments
Hello, I would love to better help, but hard to give good direction without a lot to go on. Based on what you said so far, I can confirm that |
Sorry for long delay (It seemed the answers were blocked). What I tried: const app = express();
const router = express.Router();
router.get('/users/info', function(req, res) {
res.write('info');
res.end();
});
router.get('lists', function(req, res) {
res.end('lists');
});
app.get('/home.html', function(req, res) {
res.send('/home.html');
});
app.all('/users/*', function (req, res, next) {
res.write('/users/');
next();
res.end();
}, router);
app.listen(3000); It worked. You suggested to use When testing router/app.all I expected it avoid to repeat base path but I didn't managed to avoid repetition of
I expected to have |
I come after this:
ef497fd#diff-f7dc29b565d7b8578bbabcd36d010c1eb95527acd5f1395bf3e1a2d4506360c5R425-R437
This seems to be the intended default behavior but in my case I really need namespace. If I let user query /user instead of /user/ path of css are wrong. I know of https://developer.mozilla.org/fr/docs/Web/HTML/Element/base or maybe other way to specify in html. I don't know specific header in http to update this.
I serve content I have no control over (so I can modify on the fly but would like to avoid overhead). I can't imagine a way to use a redirection ? because / in the router match no /. I have enabled strict routing (tried both syntax just in case I did a typo:
app.set('strict routing', true);
andapp.enable('strict routing');
)The text was updated successfully, but these errors were encountered: