Initial commit: TopSysOps site + admin panel
Multi-page public site (Next.js), Node/Express backend with Postgres, and Vite admin/account app, restructured from a single-page layout into dedicated service, promotions, cases, about, FAQ, and blog pages for SEO. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013otXCiTZsxdZ4SJKZ9wUky
This commit is contained in:
commit
130c5382cd
108 files changed
+7146
No files matched your search
@@ -0,0 +1,26 @@
|
||||
// Используется в клиентских компонентах ('use client'). Идёт через относительный
|
||||
// /api - в браузере это резолвится через Caddy, который проксирует на бэкенд.
|
||||
async function request(path, options = {}) {
|
||||
const res = await fetch(`/api${path}`, {
|
||||
credentials: 'same-origin',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
...options,
|
||||
});
|
||||
if (!res.ok) {
|
||||
let message = 'Request failed';
|
||||
try {
|
||||
const data = await res.json();
|
||||
message = data.error || message;
|
||||
} catch (e) {
|
||||
// no JSON body
|
||||
}
|
||||
throw new Error(message);
|
||||
}
|
||||
if (res.status === 204) return null;
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export const clientApi = {
|
||||
submitReview: (data) => request('/reviews', { method: 'POST', body: JSON.stringify(data) }),
|
||||
trackVisit: () => request('/stats/visit', { method: 'POST' }).catch(() => {}),
|
||||
};
|
||||
Reference in new issue
Block a user