-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
[Feature Request]: Allow for setting a base path for routes #478
Comments
hmm pretty hackish, I will think about it :p it would be nice to tackle this issue at the core and not just express support, since this does not fix connect middleware like staticProvider |
Yeah it certainly would, but then again, giving people a .diff with 200 lines changed... dude I just want ma repz! Just kidding, it took me like 30 minutes to come up with the thing above. I just wasn't sure how to patch the connect middleware without breaking everything else for him which uses it. If you can tell me a good way to hook this in, well I got plenty of free time ;) |
yeah tough call I will have to think about it a little. |
This would be a pretty useful feature. Right now I have references to the basePath all over the place, although, I'm sure there is a better way of doing it (like the above patch). |
we could create a connect middlware for this, quite easily actually, similar to the vhost one |
I believe 'express-contrib/namespace' does what you're trying to do: |
closing |
Sorry for bringing this ancient topic up, but was there a solution to this? The express-contrib URL given above does not work, and I don't see this kind of functionality in ExpressJS documentation. |
OK, the correct URL is https://github.com/visionmedia/express-namespace and it works. Thanks. |
I thought I could use the http://expressjs.com/guide.html#settings Why not using the Thank you. |
it shouldn't really be a setting IMO, the implementation with regexps is a hack. It's a lot easier to just use the "mounting" feature of Connect which makes that prefix/basepath transparent to the rest of the application |
The only issue I wanted to raise was that the I have a case where I want to serve And I really thought the Thank you. |
@vvo definitely, I agree. I've removed it in 3.x for that reason. there are a few ways you can do it, mounting being one but I'll make sure to add those in the new guide im writing |
People apparently want that:
http://stackoverflow.com/questions/4375554/is-it-possible-to-set-a-base-url-for-nodejs-app/
All it needs is a simple patch to
server.js
.When generating the route modify:
To this:
And the helper for patching the routes:
One can now do:
And
http://localhost:4000/myapp/test
will serverHello World
.I've tested the RegExp patching with a couple of custom expressions as well with the ones from the API Docs.
The text was updated successfully, but these errors were encountered: