Unify auth with backend cookie sessions; add dev-deploy pipeline
Auth: drop localStorage session token entirely, talk to netrunner-backend via credentials:"include" HttpOnly cookies shared over the common parent domain, and redirect to the account subdomain (ЛК) after login instead of a dead local /profile route. Config: NEXT_PUBLIC_* values used by client components (API_URL, ACCOUNT_ORIGIN, BOT_USERNAME, PB_URL) get inlined into the JS bundle at image build time and can't be overridden by docker-compose environment at container start. Moved these reads into server components (page.tsx) and thread them down as props, so one built image can genuinely serve both prod and dev by config alone. CI/CD: split the old single auto-deploy-to-prod workflow into build.yml (build+push on every push to main) and deploy.yml with deploy-dev (auto, same VPS as netrunner-backend's dev environment) and deploy-prod (manual dispatch only) — mirrors netrunner-backend's pipeline shape. Added docker-compose.dev-remote.yml pointing at the dev backend. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,12 @@ import { pb, type PBDownload, getPbFileUrl } from "@/lib/pb";
|
||||
interface DownloadClientProps {
|
||||
dict: Dictionary["download"];
|
||||
lang: string;
|
||||
/**
|
||||
* Адрес PocketBase — приходит пропсом из серверного page.tsx, а не читается
|
||||
* напрямую из process.env.NEXT_PUBLIC_* здесь (см. комментарий в
|
||||
* app/[lang]/auth/auth-client.tsx для полного объяснения).
|
||||
*/
|
||||
pbUrl: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,7 +40,7 @@ interface DownloadClientProps {
|
||||
* Платформы со статусом "dev" рендерятся приглушённо (grayscale) с единственной
|
||||
* кнопкой "уведомить о релизе".
|
||||
*/
|
||||
export function DownloadClient({ dict, lang }: DownloadClientProps) {
|
||||
export function DownloadClient({ dict, lang, pbUrl }: DownloadClientProps) {
|
||||
const [platforms, setPlatforms] = useState<PBDownload[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
@@ -42,6 +48,7 @@ export function DownloadClient({ dict, lang }: DownloadClientProps) {
|
||||
async function fetchDownloads() {
|
||||
try {
|
||||
setLoading(true);
|
||||
pb.baseURL = pbUrl;
|
||||
const records = await pb
|
||||
.collection(`downloads_${lang}`)
|
||||
.getFullList<PBDownload>({
|
||||
@@ -56,7 +63,7 @@ export function DownloadClient({ dict, lang }: DownloadClientProps) {
|
||||
}
|
||||
}
|
||||
fetchDownloads();
|
||||
}, [lang]);
|
||||
}, [lang, pbUrl]);
|
||||
|
||||
// Единый конфиг стилей: Primary (Фиолетовый) для базы, Secondary (Циан) для акцентов
|
||||
const getPlatformIcon = (platformId: string) => {
|
||||
@@ -170,7 +177,7 @@ export function DownloadClient({ dict, lang }: DownloadClientProps) {
|
||||
className="w-full h-14 rounded-2xl font-bold gap-3 bg-primary text-primary-foreground hover:bg-primary/90 shadow-[0_0_20px_rgba(139,61,255,0.3)] transition-all active:scale-[0.98]"
|
||||
>
|
||||
<a
|
||||
href={getPbFileUrl(platform, platform.file)}
|
||||
href={getPbFileUrl(platform, platform.file, pbUrl)}
|
||||
download
|
||||
>
|
||||
<Download className="size-5" />
|
||||
|
||||
@@ -9,6 +9,14 @@ export default async function DownloadPage({
|
||||
const { lang } = await params;
|
||||
const dict = await getDictionary(lang);
|
||||
|
||||
// Добавили передачу lang
|
||||
return <DownloadClient dict={dict.download} lang={lang} />;
|
||||
// Читаем PB_PUBLIC_URL, а не NEXT_PUBLIC_PB_URL: Next.js статически подставляет
|
||||
// NEXT_PUBLIC_*-переменные везде, где они встречаются в коде (в т.ч. внутри серверных
|
||||
// компонентов), на этапе `next build` — так что чтение NEXT_PUBLIC_PB_URL здесь давало бы
|
||||
// то же самое собранное-в-образ значение, что и в клиентском бандле. PB_PUBLIC_URL —
|
||||
// обычная (не NEXT_PUBLIC_) переменная, поэтому читается по-настоящему заново при каждом
|
||||
// запросе (см. подробный комментарий в app/[lang]/auth/auth-client.tsx про ACCOUNT_ORIGIN).
|
||||
const pbUrl =
|
||||
process.env.PB_PUBLIC_URL || "https://netrunner-vpn.com/cms-api";
|
||||
|
||||
return <DownloadClient dict={dict.download} lang={lang} pbUrl={pbUrl} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user