Changing pusher / back URL depending on environment

This commit is contained in:
David Négrier 2021-12-06 15:29:24 +01:00
parent 44c4b4fc34
commit 15565c9a29

View file

@ -1,16 +1,29 @@
import axios from "axios";
const fs = require('fs');
export async function getPusherDump(): Promise<any> {
let url = 'http://pusher.workadventure.localhost/dump?token=123';
if (fs.existsSync('/project')) {
// We are inside a container. Let's use a direct route
url = 'http://pusher/dump?token=123';
}
return (await axios({
url: 'http://pusher.workadventure.localhost/dump?token=123',
url,
method: 'get',
})).data;
}
export async function getBackDump(): Promise<any> {
let url = 'http://api.workadventure.localhost/dump?token=123';
if (fs.existsSync('/project')) {
// We are inside a container. Let's use a direct route
url = 'http://back/dump?token=123';
}
return (await axios({
url: 'http://api.workadventure.localhost/dump?token=123',
url,
method: 'get',
})).data;
}