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 { useEffect, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
@@ -42,7 +43,7 @@ interface Member {
|
||||
}
|
||||
|
||||
async function api<T>(url: string, init?: RequestInit): Promise<{ ok: true; data: T } | { ok: false; error: string }> {
|
||||
const res = await fetch(url, { ...init, headers: { "Content-Type": "application/json" } });
|
||||
const res = await fetch(withBase(url), { ...init, headers: { "Content-Type": "application/json" } });
|
||||
const body = await res.json().catch(() => ({}));
|
||||
return res.ok ? { ok: true, data: body as T } : { ok: false, error: body.error ?? "ทำรายการไม่สำเร็จ" };
|
||||
}
|
||||
@@ -211,7 +212,7 @@ export function PagesManager({
|
||||
<h2>บัญชี Facebook</h2>
|
||||
{appConfigured ? (
|
||||
// Full navigation (not <Link>): the start route redirects to facebook.com.
|
||||
<a href="/api/facebook/oauth/start" className="btn btn-primary btn-sm ml-auto">
|
||||
<a href={withBase("/api/facebook/oauth/start")} className="btn btn-primary btn-sm ml-auto">
|
||||
<Icon name="link" size={14} /> {connections.length ? "เชื่อมบัญชีเพิ่ม / ขอสิทธิ์ใหม่" : "เข้าสู่ระบบด้วย Facebook"}
|
||||
</a>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user