summaryrefslogtreecommitdiff
path: root/apps/web/app/api
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-08 02:35:39 -0800
committerFuwn <[email protected]>2026-02-08 02:35:39 -0800
commit75706083f735c2705bbdc814b9013adfe6adbf7b (patch)
treed3c63c717fb8b2df109ac3ce96a03c27ebd6b34a /apps/web/app/api
parentfeat: add feed management features and fix subscribe_to_feed bugs (diff)
downloadasa.news-75706083f735c2705bbdc814b9013adfe6adbf7b.tar.xz
asa.news-75706083f735c2705bbdc814b9013adfe6adbf7b.zip
fix: share clipboard write for Safari transient activation
- Use ClipboardItem with Promise to preserve user gesture context - Fall back to showing share URL in toast if clipboard is unavailable - Derive app origin from request URL when NEXT_PUBLIC_APP_URL is unset - Add onError handlers to share/unshare mutations
Diffstat (limited to 'apps/web/app/api')
-rw-r--r--apps/web/app/api/share/route.ts17
1 files changed, 6 insertions, 11 deletions
diff --git a/apps/web/app/api/share/route.ts b/apps/web/app/api/share/route.ts
index e1252bf..b6a9c88 100644
--- a/apps/web/app/api/share/route.ts
+++ b/apps/web/app/api/share/route.ts
@@ -4,10 +4,11 @@ import { createSupabaseServerClient } from "@/lib/supabase/server"
const MAX_NOTE_LENGTH = 1000
-function getAppOrigin(): string | null {
- const url = process.env.NEXT_PUBLIC_APP_URL
- if (!url) return null
- return url.replace(/\/$/, "")
+function getAppOrigin(request: Request): string {
+ const envUrl = process.env.NEXT_PUBLIC_APP_URL
+ if (envUrl) return envUrl.replace(/\/$/, "")
+ const requestUrl = new URL(request.url)
+ return requestUrl.origin
}
export async function POST(request: Request) {
@@ -90,13 +91,7 @@ export async function POST(request: Request) {
)
}
- const origin = getAppOrigin()
- if (!origin) {
- return NextResponse.json(
- { error: "application URL is not configured" },
- { status: 500 }
- )
- }
+ const origin = getAppOrigin(request)
const { data: existingShare } = await supabaseClient
.from("shared_entries")