Skip to content

Use webpack dev server instead of a custom proxy#19

Open
bn3t wants to merge 1 commit into
onpaws:masterfrom
bn3t:feature/use-webpack-devserver-as-proxy
Open

Use webpack dev server instead of a custom proxy#19
bn3t wants to merge 1 commit into
onpaws:masterfrom
bn3t:feature/use-webpack-devserver-as-proxy

Conversation

@bn3t

@bn3t bn3t commented Jan 8, 2022

Copy link
Copy Markdown

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