Skip to content

Commit

Permalink
Make sync server endpoints path-relative (#48)
Browse files Browse the repository at this point in the history
This backwards-compatible change allows the sync server endpoint to include a path, e.g. https://example.com/syncserver/, and facilitates serving the Prompta app and sync server from the same host.
  • Loading branch information
struanb authored Oct 7, 2024
1 parent dad5d4a commit c6c4821
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/stores/stores/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ export const syncStore = (() => {

const healthcheck = async () => {
const endpoint = get(serverConfig).endpoint;
const u = new URL("/health", endpoint);
const u = new URL("./health", endpoint);
const res = await fetch(u).then((x) => (x.ok ? x.json() : Promise.reject(x)));

if (res.status === "ok" && res.n === 47) {
Expand Down Expand Up @@ -767,7 +767,7 @@ export const syncStore = (() => {

const registerSchema = async (schemaName: string, content: string) => {
const endpoint = get(serverConfig).endpoint;
const u = new URL("/schema", endpoint);
const u = new URL("./schema", endpoint);
const res = await fetch(u, {
method: "POST",
body: JSON.stringify({ schemaName, content }),
Expand Down Expand Up @@ -838,7 +838,7 @@ export const syncStore = (() => {

console.debug("register schema ::", schema_name, result);

const syncEndpoint = new URL("/changes", get(serverConfig).endpoint).href;
const syncEndpoint = new URL("./changes", get(serverConfig).endpoint).href;
syncAdapter = await createSyncer({
db: _db,
endpoint: syncEndpoint,
Expand Down

0 comments on commit c6c4821

Please sign in to comment.