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

Proxy '/socket.io' to socket server #1418

Merged
merged 2 commits into from May 21, 2020

Conversation

nddery
Copy link
Collaborator

@nddery nddery commented Apr 30, 2020

Description

Rework how the communication with SocketIO is done. Instead of talking directly with the SocketIO server, proxy the /socket.io path to the SocketIO domain.

Changes/Tasks

  • Initialize the SocketIO client without options (defaults to current window location)
  • Proxy /socket-io to the SocketIO server
  • Remove the __getMessagePort endpoint in the webpack-dev-server

Motivation and Context

Following the steps outlined in the documentation to enable HTTPS for local development, Safari fails to request data from the SocketIO domain (http://localhost:4000), has it isn't served over HTTPS. Chrome has no issue with this.

Safari logs the following error in the console, originating from polling-xhr.js:

Not allowed to request resource
XMLHttpRequest cannot load http://localhost:4000/socket.io/?EIO=3&transport=polling&t=N7DEOQw due to access control checks.

I have tried to run the SocketIO server on an HTTPS server, without any luck.

Types of changes

  • Refactoring/add tests (refactoring or adding test which isn't a fix or add a feature)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I have updated the documentation accordingly
  • I have updated the CHANGELOG with a summary of my changes
  • My changes have tests around them

Safari prevents sites served over HTTPS from communicating with some server over HTTP. This ensure that when someone has configured webpack-dev-server to be served over HTTPS, that request for the socket.io server still function.
Copy link
Member

@SleeplessByte SleeplessByte left a comment

Choose a reason for hiding this comment

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

Seems fine. Annoying tho!

Thanks for this.

@SleeplessByte SleeplessByte merged commit f847386 into react-static:master May 21, 2020
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.

None yet

2 participants