Skip to content
This repository

Add support for configuring the client-side socket.io's path (better reverse-proxy support) #154

Merged
merged 2 commits into from over 2 years ago

2 participants

dcolens Eric Zhang
dcolens

Using the client.socketio.resource option to set the path for socket.io.js instead of using the hardcoded default value of /socket.io/socket.io.js.
client.socketio.resource defaults to socket.io.

Eric Zhang ericz merged commit db4cfb0 into from
Eric Zhang ericz closed this
Eric Zhang

Thanks for the contribution @dcolens. Sorry for taking so longer to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 7 additions and 1 deletion. Show diff stats Hide diff stats

  1. +4 0 doc/public/user_manual.md
  2. +3 1 lib/client/now.js
4 doc/public/user_manual.md
Source Rendered
@@ -217,6 +217,10 @@ available options and their defaults:
217 217 // Do note that the object that this points to should already exist by the time now.js is loaded.
218 218 }
219 219
  220 +If the `client.socketio.resource` option is set it will also be used
  221 +for the path of the socket.io.js file. This option can be useful in
  222 +the case of a reverse proxy setup.
  223 +
220 224 If the options object is incomplete, the default values will be used
221 225 in place of any missing options.
222 226
4 lib/client/now.js
@@ -6,6 +6,8 @@
6 6 return nowObjects[uri];
7 7 }
8 8 options = options || {};
  9 + options.socketio = options.socketio || {};
  10 + options.socketio.resource = options.socketio.resource || "socket.io";
9 11
10 12 var socket;
11 13 var closures = {};
@@ -535,7 +537,7 @@
535 537 };
536 538
537 539 var dependencies = [
538   - { key: 'io', path: '/socket.io/socket.io.js'}
  540 + { key: 'io', path: '/' + now.core.options.socketio.resource + '/socket.io.js'}
539 541 ];
540 542 var dependenciesLoaded = 0;
541 543

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.