Browse Source

Proper switch between http and https

transifex
Nicolas Pomepuy 3 years ago
parent
commit
30eb9985d5
  1. 6
      buildsystem/network-sharing-server/src/App.vue
  2. 9
      buildsystem/network-sharing-server/src/config.js

6
buildsystem/network-sharing-server/src/App.vue

@ -57,7 +57,11 @@ export default {
},
startWebSocket() {
console.log("Starting connection to WebSocket Server")
this.connection = new WebSocket("ws://" + API_IP + "/echo", "player")
let protocol = "wss"
if (location.protocol !== 'https:') {
protocol = `ws`;
}
this.connection = new WebSocket(`${protocol}://${API_IP}/echo`, "player")
this.connection.onmessage = (event) => {
const msg = JSON.parse(event.data);

9
buildsystem/network-sharing-server/src/config.js

@ -1,6 +1,13 @@
const API_PORT = "8080"
export const API_IP = process.env.NODE_ENV === 'development' ? `${process.env.VUE_APP_DEVICE_IP}:${API_PORT}` : `${location.host}`
export const API_URL = `http://${API_IP}/`;
export let API_URL;
if (location.protocol !== 'https:') {
API_URL = `http://${API_IP}/`;
} else {
API_URL = `https://${API_IP}/`;
}
export const API_CONFIG = {
LIST_LOGFILES: `${API_URL}list-logfiles`,

Loading…
Cancel
Save