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

Do not add trailing slash to websocket path #28

Merged
merged 1 commit into from
Apr 3, 2023

Conversation

joelochlann
Copy link
Member

@joelochlann joelochlann commented Mar 17, 2023

When using Hot Module Reloading (HMR) with Create React App (i.e. WebPack under the hood), the WebSockets server is listening at /sockjs-node for CRA/WebPack v4:

Screenshot 2023-03-20 at 09 55 17

and at /ws for v5:

Screenshot 2023-03-20 at 10 01 22

Since dev-nginx adds a trailing slash to the nginx config, it fails to proxy these through correctly:

Screenshot 2023-03-20 at 10 01 44

Removing the trailing slash fixes the issue:

Screenshot 2023-03-20 at 10 03 07

@joelochlann joelochlann marked this pull request as ready for review March 20, 2023 10:05
Copy link
Member

@akash1810 akash1810 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessarily a CRA exclusive fix, as what we're actually doing is exactly following the configuration provided by the user. This matches the handling of path below when creating the HTTP reverse proxy. Hopefully this isn't too controversial.

Looking at usage of dev-nginx setup-app across the organisation, I can't see any service that this change will negatively impact. In some cases, it'll actually make them easier to run!

@akash1810
Copy link
Member

akash1810 commented Mar 21, 2023

I suspect the trailing / was a typo from https://github.com/guardian/dev-nginx-old/commit/c2d033477dc2925345b5e4d8c91148d1e5d1314e 1.

Footnotes

  1. See the original email and the dev-nginx-old README for details on why we've got two repositories.

@joelochlann
Copy link
Member Author

In some cases, it'll actually make them easier to run!

Good find - so Michael figured this out ages ago! 😂 Shame he wasn't still on the team when I started digging into this

@joelochlann joelochlann merged commit 9ad4533 into main Apr 3, 2023
joelochlann added a commit to guardian/homebrew-devtools that referenced this pull request Apr 3, 2023
akash1810 pushed a commit to guardian/homebrew-devtools that referenced this pull request Apr 3, 2023
akash1810 pushed a commit to guardian/homebrew-devtools that referenced this pull request Apr 3, 2023
joelochlann added a commit to guardian/homebrew-devtools that referenced this pull request Apr 4, 2023
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.

2 participants