making login work for prod
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import { Preferences } from '@capacitor/preferences';
|
||||
const env = import.meta.env
|
||||
|
||||
class Connection {
|
||||
connectionTries = 0;
|
||||
ws;
|
||||
@@ -8,10 +11,14 @@ class Connection {
|
||||
}
|
||||
|
||||
init = async () => {
|
||||
const { value: token } = await Preferences.get({ key: 'auth_token' });
|
||||
return new Promise((resolve, reject) => {
|
||||
const url = window.location.hostname.includes("local")
|
||||
? "ws://" + window.location.host + "/ws"
|
||||
: "wss://" + window.location.hostname + window.location.pathname + "/ws";
|
||||
let url = ""
|
||||
if(env.VITE_API_URL) {
|
||||
url = "wss://" + env.VITE_API_URL.replace(/^https?:\/\//, '') + "/ws" + `?token=${token}`;
|
||||
} else {
|
||||
url = "ws://" + window.location.host + "/ws"
|
||||
}
|
||||
|
||||
this.ws = new WebSocket(url);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user