Changed endpoints to environment variables.

This commit is contained in:
Michael Mainguy 2023-11-07 06:55:57 -06:00
parent f51b5d9e7c
commit c42772ce47
2 changed files with 13 additions and 2 deletions

11
src/env.d.ts vendored Normal file
View File

@ -0,0 +1,11 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_SYNCDB_ENDPOINT: string,
readonly VITE_SYNCDB_USER: string
// more env variables...
}
interface ImportMeta {
readonly env: ImportMetaEnv
}

View File

@ -213,10 +213,10 @@ export class PouchdbPersistenceManager implements IPersistenceManager {
try {
const syncTarget = "user123";
const dbs = await axios.get('https://syncdb-service-d3f974de56ef.herokuapp.com/_all_dbs');
const dbs = await axios.get(import.meta.env.VITE_SYNCDB_ENDPOINT);
if (dbs.data.indexOf(syncTarget) == -1) {
console.log('sync target missing');
const buildTarget = await axios.post('https://deepdiagram.com/.netlify/functions/users',
const buildTarget = await axios.post(import.meta.env.VITE_USER_ENDPOINT,
{username: syncTarget, password: 'password', db: syncTarget});
if (buildTarget.status != 200) {
console.log(buildTarget.statusText);