Skip to content

Commit efcaff3

Browse files
authored
Merge pull request #113 from AlgorithmicGames/new-backend
New backend
2 parents 2558cf9 + 209459b commit efcaff3

1 file changed

Lines changed: 4 additions & 20 deletions

File tree

Backend.js

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
11
'use strict'
2-
class Backend{
3-
static call(module='', data){
4-
let backend = Backend.getBackend();
5-
return fetch(new Request(backend.path+'/'+module), {
2+
class Backend {
3+
static call(module='', data) {
4+
return fetch(new Request(BackendService.getBackend()+'/'+module), {
65
method: 'POST',
7-
headers: new Headers(backend.headers),
86
body: JSON.stringify(data)
97
});
108
}
119
static getBackend(){
12-
try{
13-
let backend = localStorage.getItem('backend');
14-
if(backend){
15-
return JSON.parse(backend);
16-
}
17-
}catch(e){
18-
console.error('Invalid backend');
19-
}finally{
20-
return {
21-
path: 'https://nfegdyrzrdhwvqpujxhj.functions.supabase.co',
22-
headers: {
23-
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTY0MzY2MTc3MCwiZXhwIjoxOTU5MjM3NzcwfQ.x_SvsnLkgYNEgpxa7h74Z__aBgGbGIYVmljhwYDJ1Bc'
24-
}
25-
};
26-
}
10+
return localStorage.getItem('backend') ?? 'https://backend.algorithmic.games';
2711
}
2812
static isOverride(){
2913
return localStorage.getItem('backend') !== null;

0 commit comments

Comments
 (0)