diff --git a/packages/op-arcade-sdk/src/stores.js b/packages/op-arcade-sdk/src/stores.js index 8c2c459..80bbe0d 100644 --- a/packages/op-arcade-sdk/src/stores.js +++ b/packages/op-arcade-sdk/src/stores.js @@ -19,6 +19,11 @@ export const isTournament = writable(false); export const tourneyStore = getTourneyStore(); export const authStore = getAuthStore(); +export const NODE_API_URL = writable({ + dev: "http://127.0.0.1:3001/oparcade/api", + prod: "http://op-arcade-dev.herokuapp.com/oparcade/api" +}) + export async function useServers(options) { let auth_provider = await get(authStore).useServer(options.auth_server); let tourney_provider = await get(tourneyStore).useServer(options.tourney_server, auth_provider); diff --git a/packages/op-arcade-sdk/src/tourney/nakama.js b/packages/op-arcade-sdk/src/tourney/nakama.js index 981e7e5..e621c78 100644 --- a/packages/op-arcade-sdk/src/tourney/nakama.js +++ b/packages/op-arcade-sdk/src/tourney/nakama.js @@ -1,7 +1,8 @@ import CONSTANTS from '../constants.js' import * as nakamajs from '@heroiclabs/nakama-js'; -// const axios = require('axios') +import {get} from 'svelte/store' +import {isProd, NODE_API_URL} from '../stores' import axios from 'axios' const TEST_ID = "test_id" @@ -95,11 +96,9 @@ class NakamaTourneyProvider { } } - const dev = 'http://127.0.0.1:3001/oparcade/api/tournaments/post-score' - const prod = 'http://op-arcade-dev.herokuapp.com/oparcade/api/tournaments/post-score' - const isDevelopment = false - const requestURL = isDevelopment ? dev : prod - const res = await axios.post(requestURL, args, config) + const {prod, dev} = get(NODE_API_URL) + const requestURL = get(isProd) ? prod : dev + const res = await axios.post(`${requestURL}/tournaments/post-score`, args, config) return res } catch (e) { console.error("postScore failed [" + e.status + ":" + e.statusText + "]");