Parcel + http-proxy
For more, check out my blog post on the subject, which goes into deeper detail.
Loosely follows: https://github.com/nodejitsu/node-http-proxy/blob/master/test/lib-http-proxy-passes-web-incoming-test.js#L412
This is for creating a proxying dev server, making use of parcel's built-in dev server, and forwarding back-end calls (such as /api/
). This does this all without using express or express middleware, but rather using http-proxy
directly.
Why is this a concern? There is a great example, for those using express, on how to use parcel as middleware, but this requires use of express. My example uses Node's built-in http
and the published http-proxy
packages directly.
*note: I really like express, but I didn't feel like needing a third dev server installed was really needed
This is best invoked through an npm script, decalred in package.json
such as:
"scripts": {
"dev": "node dev-server.js",