Change the websocket URL /websocket

Hi all,

I’ve trying to find a way to change the websocket URL, like this:

I have 2 meteor apps running on the same server & domain and would like to configure the Apache server to proxy URLs and their websockets to the appropriate app based on URL:

https://{DOMAIN}/login (app 1)
https://{DOMAIN}/admin (app 1)
wss://{DOMAIN}/websocket-admin (app 1)

https://{DOMAIN}/* (app 2)
wss://{DOMAIN}/websocket (app 2)

Any help would be appreciated.

This might not match your overall url schema, but you can set one Meteor app to behind a path like /admin/* by setting the environment variable ROOT_URL to include /admin/.

Then Meteor sets that path as the path-prefix that’s used for the websocket url here:

Alternatively, you can use a local fork of ddp-server with the websocket-url of your choosing. You’ll also need to tell the client where to connect to. This is probably easiest done with the DDP_DEFAULT_CONNECTION_URL environment variable, but you’ll need to experiment a bit.

You can make local forks of core packages by copying the package folder from Meteor’s github into your /packages folder. Meteor always checks the packages/ folder first when deciding which version of a package to use

Thanks coagmano, I ended doing your first suggestion, appending /admin to the ROOT_URL. I had to mess up with the routing in the app but that seems to work fine now.


1 Like

Really small note on this - this doesn’t play nice with cordova (if that’s on your roadmap) - it hardcodes URL_PREFIX to “/”

1 Like