fixed cors
This commit is contained in:
@@ -3,9 +3,10 @@ import { routes } from './routes.js';
|
||||
let DEBUG = true;
|
||||
window.DEBUG = DEBUG;
|
||||
|
||||
let SERVER_URL;
|
||||
let SERVER_HOST;
|
||||
if (DEBUG) SERVER_HOST = 'localhost';
|
||||
else SERVER_HOST = 'a2s.su';
|
||||
window.SERVER_HOST = SERVER_HOST;
|
||||
|
||||
/* main */
|
||||
window.onload = function () {
|
||||
@@ -75,12 +76,18 @@ const location_handler = async () => {
|
||||
};
|
||||
|
||||
function get_from_api(callback, api_method = '', params = {}) {
|
||||
respone = '';
|
||||
|
||||
if (api_method == '') {
|
||||
console.log('wrong method');
|
||||
} else {
|
||||
fetch(`http://${SERVER_HOST}:3000/api/v1.0/${api_method}`)
|
||||
let url = `http://${SERVER_HOST}:3000/api/v1.0/${api_method}`;
|
||||
let opts = {
|
||||
method: 'get',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
fetch(url, opts)
|
||||
.then((response) => {
|
||||
return response.json();
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user