From fe27556e72fbe99719321ef7df58427febe8cddb Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 25 Nov 2026 09:50:53 -0700 Subject: 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 Claude-Session: https://claude.ai/code/session_01VMan6W9CsdxmhFrfaKNVHU --- src/routes/(app)/post/[...path]/+server.ts | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/routes/(app)') 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), + }, }); } -- cgit v1.2.3