aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-11-25 09:50:53 -0700
committerAdam Soltys <[email protected]>2026-11-25 09:50:53 -0700
commitfe27556e72fbe99719321ef7df58427febe8cddb (patch)
treea20b62bc7be1e3616d5089681cf611d2f6581d6b /src/routes
parent3a321d4e70d1244224c4643ddac8e96216bfe5f4 (diff)
downloadcoinos-ui-fe27556e72fbe99719321ef7df58427febe8cddb.tar.gz
coinos-ui-fe27556e72fbe99719321ef7df58427febe8cddb.zip
Remove the Shopify integration; tighten the post relay
Drop the Shopify settings page and script route along with the unused ecash post route. The generic post relay now only forwards plain API paths and passes the visitor's address along to the API. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6W9CsdxmhFrfaKNVHU
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/(app)/post/[...path]/+server.ts25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/routes/(app)/post/[...path]/+server.ts b/src/routes/(app)/post/[...path]/+server.ts
index 84df9a36..530bd2ed 100644
--- a/src/routes/(app)/post/[...path]/+server.ts
+++ b/src/routes/(app)/post/[...path]/+server.ts
@@ -1,12 +1,29 @@
import { PUBLIC_COINOS_URL as base } from "$env/static/public";
-import { auth } from "$lib/utils";
+import { auth, ipHeaders } from "$lib/utils";
+import { error } from "@sveltejs/kit";
+
+// Relays a signed-in browser's POST to the API. The API trusts callers that
+// arrive without a client address (its own node containers), so this must
+// always pass the visitor's address along, and must only ever produce a plain
+// API path: no absolute URLs, no "..", no empty segments.
+const segment = /^[A-Za-z0-9_.~@:-]+$/;
+const internalOnly = new Set(["confirm"]);
export async function POST({ cookies, fetch, params, request }) {
- const { path } = params;
+ const parts = params.path.split("/");
+ if (
+ !parts.every((p) => segment.test(p) && p !== "." && p !== "..") ||
+ internalOnly.has(parts[0].toLowerCase())
+ )
+ error(404, "Not found");
- return fetch(`${base}/${path}`, {
+ return fetch(`${base}/${parts.join("/")}`, {
method: "POST",
body: JSON.stringify(await request.json()),
- headers: { "Content-Type": "application/json", ...auth(cookies) },
+ headers: {
+ "Content-Type": "application/json",
+ ...ipHeaders(),
+ ...auth(cookies),
+ },
});
}