Skip to content
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

Use webpack dev server instead of a custom proxy #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bn3t
Copy link

@bn3t bn3t commented Jan 8, 2022

Thank you for the great example. I was looking for such a solution for quite some time!

I wanted to propose an improvement to how client/server are run in development. This changes reverts the responsibility of which is doing proxying on behalf of the client to avoid CORS (in the development setup). To me it makes more sense to have proxying done by the client part as webpack dev server supports that feature out of the box. It has several advantages, I think:

  • The backend does not need to care of proxying requests for the frontend
  • In the client the urls to the backend are not full URLs (http://localhost:4000/path) only absolute URLs (/path). It shows in the changes I did in Apollo.js and in useAuth.js.
  • In my experience, this setup ressembles more the target production installation where the frontend would served statically by an nginx or Apache server, in addition to having a reverse proxy or a load balancer to provide access to the backend. All are served from the same origin.

Thanks in advance for considering merging this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant