diff --git a/.env b/.env index 86d3441..75424e4 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ VUE_APP_TITLE=Jelly-Party -VUE_APP_MODE=production \ No newline at end of file +VUE_APP_MODE=production +VUE_APP_WS_ADDRESS=wss://ws.jelly-party.com:8080 \ No newline at end of file diff --git a/.env.staging b/.env.staging index 0a485a1..0a38d58 100644 --- a/.env.staging +++ b/.env.staging @@ -1,3 +1,4 @@ NODE_ENV=development VUE_APP_TITLE=STAGE-BUILD -VUE_APP_MODE=staging \ No newline at end of file +VUE_APP_MODE=staging +VUE_APP_WS_ADDRESS=wss://staging.jelly-party.com:8080 \ No newline at end of file diff --git a/README.md b/README.md index 77477fe..b6900d3 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,10 @@ Note that you'll connect to the staging server (`staging.jelly-party.com`) inste ## Contribute using your own server [advanced] -Please head to the [Jelly-Party-Server](https://github.com/seandlg/jelly-party-server) repository and spin up a server instance. You must set up your custom domain and you'll need to tweak both Jelly-Party-Extension and Jelly-Party-Server. +Please head to the [Jelly-Party-Server](https://github.com/seandlg/jelly-party-server) repository and spin up a server instance. You must set up your custom domain. You'll need to tweak Jelly-Party-Server. + +To use your server by the browser extension define environment variable `VUE_APP_WS_ADDRESS`. You could save it in a new file `.env.local` or `.env.[mode].local`. For more information see [Vue CLI Modes and Environment Variables](https://cli.vuejs.org/guide/mode-and-env.html). + ### Compile and minify for production diff --git a/src/apps/sidebar/Vue-IFrame/Vue-IFrame.ts b/src/apps/sidebar/Vue-IFrame/Vue-IFrame.ts index 197b680..041bb2e 100644 --- a/src/apps/sidebar/Vue-IFrame/Vue-IFrame.ts +++ b/src/apps/sidebar/Vue-IFrame/Vue-IFrame.ts @@ -200,14 +200,7 @@ export class JellyParty { store.dispatch("options/setLastPartyId", finalPartyId); // Set the magic link this.updateMagicLink(); - let wsAddress = ""; - switch (this.rootState.appMode) { - case "staging": - wsAddress = "wss://staging.jelly-party.com:8080"; - break; - default: - wsAddress = "wss://ws.jelly-party.com:8080"; - } + const wsAddress = process.env.VUE_APP_WS_ADDRESS ?? "wss://ws.jelly-party.com:8080"; log.debug(`Jelly-Party: Connecting to ${wsAddress}`); this.ws = new WebSocket(wsAddress); store.dispatch("setConnectingToServer", true); diff --git a/src/manifest.json b/src/manifest.json index cf23bcd..d8c02ab 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -29,6 +29,6 @@ "128": "images/logo/128x128.png" }, "manifest_version": 2, - "content_security_policy": "script-src 'self'; connect-src 'self' wss://staging.jelly-party.com:8080 wss://ws.jelly-party.com:8080; object-src 'self'", + "content_security_policy": "script-src 'self'; connect-src 'self'; object-src 'self'", "web_accessible_resources": ["js/rootStyles.js", "iframe.html", "join.html"] } diff --git a/vue.config.js b/vue.config.js index 1b27c6d..5cd141c 100644 --- a/vue.config.js +++ b/vue.config.js @@ -29,7 +29,9 @@ module.exports = { }, manifest: { cspAppender: (manifest) => { - let csp = [] + let csp = [ + {key: 'connect-src', value: process.env.VUE_APP_WS_ADDRESS} + ]; if (["staging", "development"].includes(process.env.NODE_ENV)) { csp = csp.concat([ {key: 'script-src', value: "'unsafe-eval'"},