-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Proxy to Rest API #281
Comments
There are discussions about how to allow the usage of custom webpack configurations (#40 and #222), that will allow you to use the webpack's proxy configuration. Meanwhile you can run your API in another port or made use of NGINX as a reverse proxy to do that (I think the different port is the best for development right now because it doesn't require to configure a NGINX). In production you can use NGINX as a reverse proxy, so the user made a HTTP request to the NGINX server and it will map the requests to the next.js servers (you can have multiple and load-balance them) or if the request are in |
Great comment by @sergiodxa. We should probably start a wiki page on this as well. tl;DR: We recommend talking from Keep server APIs separate. Keep your Next.js app small and scoped to the frontend code. |
I have a couple of questions about how server side rendering would work my existing API. How can I run an API under the same port during development? For example, with create-react-app, I would use webpack's proxy configuration. Is there some similar configuration that I can use with next?
Also, in production, how would I run an API and still take advantage of the server side rendering from next?
I'm sure there are simple answers to these questions. I feel like I'm missing some fundamental concepts. Thanks for the help.
The text was updated successfully, but these errors were encountered: