connect to correct backend url

This commit is contained in:
Maxi Quoß
2023-01-29 19:26:48 +01:00
parent bab9648d53
commit b5fb030ddc
6 changed files with 3082 additions and 2182 deletions

View File

@@ -63,7 +63,7 @@ go mod tidy
go run main.go serve
```
Log in to [http://127.0.0.1:8090/\_/](http://127.0.0.1:8090/_/), create an admin user and add some devices.
Log in to [http://localhost:8090/\_/](http://localhost:8090/_/), create an admin user and add some devices.
2. Start frontend

5237
frontend/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -15,11 +15,11 @@
export let now;
function shutdown() {
fetch(`${dev ? 'http://127.0.0.1:8090' : ''}/api/upsnap/shutdown/${device.id}`);
fetch(`${dev ? 'http://localhost:8090' : ''}/api/upsnap/shutdown/${device.id}`);
}
function wake() {
fetch(`${dev ? 'http://127.0.0.1:8090' : ''}/api/upsnap/wake/${device.id}`);
fetch(`${dev ? 'http://localhost:8090' : ''}/api/upsnap/wake/${device.id}`);
}
function sortPorts(a, b) {

View File

@@ -79,7 +79,7 @@
buttons.scan.state = 'waiting';
await pb.collection('settings').update(settings.id, settings);
fetch(`${dev ? 'http://127.0.0.1:8090' : ''}/api/upsnap/scan`)
fetch(`${dev ? 'http://localhost:8090' : ''}/api/upsnap/scan`)
.then((res) => res.json())
.then((data) => {
if (data.message) {

View File

@@ -1,7 +1,14 @@
import { writable } from 'svelte/store';
import PocketBase from 'pocketbase';
const pb = new PocketBase('http://127.0.0.1:8090');
let backend_url;
let isDevMode = import.meta.env.DEV;
if (isDevMode) {
backend_url = 'http://localhost:8090';
} else {
backend_url = '/';
}
const pb = new PocketBase(backend_url);
pb.autoCancellation(false);
export const pocketbase = writable(pb);

View File

@@ -1,7 +1,7 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
const config = {
plugins: [sveltekit()]
};
export default config;
export default defineConfig({
plugins: [sveltekit()],
envPrefix: 'UPSNAP'
});