-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
added --proxy path@url command line argument #157
base: master
Are you sure you want to change the base?
Conversation
Feature/default index
improving API use
…e/watchify-api Conflicts: README.md package.json
Add newline to end of help.txt
fixed typo
…/localhost:3000/api)
Cool, thanks for PR! I've never used proxies, can you give an example of when it would come in handy? How do I test for it? Is that dependency going to add significant bloat to budo? Cheers 🙌 Sent from my iPhone
|
This is something better solved with a middleware IMO. I actually made one for this express purpose: https://www.npmjs.com/package/middleware-proxy
|
That's what I did at first but grew bored of always writing a config. A simple --proxy command line is quick and does all that I need.
If you have any kind of backend or API that your front-end depends on you'd have to write a config to run the budo server in tandem (attach as middleware) with your backend. With the command line you could proxy directly to your backend/api without writing a config.
I could write tests for it. Basically could run an express app and see if the proxy works.
It's a pretty thin lib with full proxy support, <1000LOC, http-proxy depends on; https://github.com/nodejitsu/node-http-proxy/blob/master/package.json ..You could move budo's request devDependency to dependencies and write a not really smaller and less complete (like what middleware-proxy does) proxy -- But request is a huge library and would add much more bloat if it were in dependencies. |
…ts at test/test-proxy.js, added vim tmp files to .gitignore
I added tests and switched to using opts.proxy so it works like the others like --live. The tests uses a node.js http server as a temporary backend api to test against: https://github.com/talmobi/budo/blob/master/test/test-proxy.js |
Ok so it appears travis passes on all node version except node version 0.8 - probably something to do with the http.createServer... I'll check [EDIT]: It looks like http-proxy isn't supported on node v0.8 - is node v0.8 support important for anyone still? |
eg:
--proxy /api@http://localhost:3000/api
Proxies request to given url from given path (for example when proxying to API server)
working sample:
budo scripts/main.js --live --proxy /api@http://localhost:3030/api -- -t rollupify -t sassr -t babelify