Support sub-path deploy via NEXT_PUBLIC_BASE_PATH (loma.chat/pagiva)
Adds basePath config, withBase/appUrl helpers, base-path-aware cookies, OAuth redirects, manifest, service worker and cron runner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"use client";
|
||||
import { withBase } from "@/lib/base-path";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
@@ -41,7 +42,7 @@ export function RulesManager({ pageId, canEdit, rules }: { pageId: string; canEd
|
||||
if (!editing) return;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
const res = await fetch("/api/reply-rules", {
|
||||
const res = await fetch(withBase("/api/reply-rules"), {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ ...editing, pageId, keywords: keywordsText }),
|
||||
@@ -54,7 +55,7 @@ export function RulesManager({ pageId, canEdit, rules }: { pageId: string; canEd
|
||||
}
|
||||
|
||||
async function toggle(rule: Rule) {
|
||||
await fetch("/api/reply-rules", {
|
||||
await fetch(withBase("/api/reply-rules"), {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ ...rule, pageId, isActive: !rule.isActive }),
|
||||
@@ -64,7 +65,7 @@ export function RulesManager({ pageId, canEdit, rules }: { pageId: string; canEd
|
||||
|
||||
async function remove(rule: Rule) {
|
||||
if (!window.confirm(`ลบกฎ "${rule.name}"?`)) return;
|
||||
await fetch(`/api/reply-rules?id=${rule.id}`, { method: "DELETE" });
|
||||
await fetch(withBase(`/api/reply-rules?id=${rule.id}`), { method: "DELETE" });
|
||||
router.refresh();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user