5 ms·
Not clear to me from the release notes if there now is an easy way to proxy to a server in development (if you for instance have a Django driven API on port 800
by erokar 8y ago
Not clear to me from the release notes if there now is an easy way to proxy to a server in development (if you for instance have a Django driven API on port 8000). This is easily done with create-react-app by just adding a line in package.json.
In Next you've had to either set up and configure nginx locally or proxia via an Express server, both options that that are a bit of a hassle to set up for such a common case.
- timneutkens 8y agocreate-react-app is actually removing this feature in an upcoming release. We don't have plans to include it as a feature to Next.js as you can already implement it using a custom server. We do have an example for it: https://github.com/zeit/next.js/tree/canary/examples/with-custom-reverse-proxy https://github.com/zeit/next.js/tree/canary/examples/with-cu...
- thrower123 8y agoWhy is it being removed?
- pests 8y agoTo let an external express server handle it. Which they think will be better than the current in house solution.
- dntrkv 8y agoSetting up http-proxy-middleware via Express in a Next.js app is under 10 lines of code.
- justsee 8y agoIn a Next.js + Now context you'd use the path alias feature [1] of now in production, using a rules.json file to do the route mappings to other microservices or external URLs. In development you'd use micro-proxy [2] and define a rules-dev.json with local mappings, and then have a package.json script to fire up that proxy for local testing. [1] https://zeit.co/docs/features/path-aliases#path-alias https://zeit.co/docs/features/path-aliases#path-alias [2] https://github.com/zeit/micro-proxy https://github.com/zeit/micro-proxy
- true_religion 8y agoI have done it in the reverse way: have django act to proxy requests to the node server. That way ypu can use django sessions, authentication, login, admin, etc. The node server just does rendering, and creates client side JS based on data it is given by Django. It took 25 lines of code, yes, but pretty much worth it if you have a long term project like a single app that your company is built around.