On this page
Handling CORS
Configuration
Since Socket.IO v3, you need to explicitly enable Cross-Origin Resource Sharing (CORS).
|
All options will be forwarded to the cors package. The complete list of options can be found here.
Example with cookies (withCredentials) and additional headers:
|
Note: this also applies to localhost if your web application and your server are not served from the same port
|
Troubleshooting
|
If you have properly configured your server (see above), this could mean that your browser wasn’t able to reach the Socket.IO server.
The following command:
|
should return something like:
|
If that’s not the case, please check that your server is listening and is actually reachable on the given port.
© 2014–2021 Automattic
Licensed under the MIT License.
https://socket.io/docs/v3/handling-cors