dockerfile update and login

This commit is contained in:
2026-04-25 17:46:25 +07:00
parent b7dd46d7ba
commit e2a1caf720
2 changed files with 41 additions and 9 deletions
+18 -1
View File
@@ -24,7 +24,6 @@ COPY package.json pnpm-lock.yaml* ./
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \ RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile pnpm install --frozen-lockfile
# --- Stage 2: Сборка Next.js ---
# --- Stage 2: Сборка Next.js --- # --- Stage 2: Сборка Next.js ---
FROM node:20-alpine AS builder FROM node:20-alpine AS builder
WORKDIR /app WORKDIR /app
@@ -41,3 +40,21 @@ RUN cp matrix-engine/matrix_worker.js public/wasm-matrix/
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1
RUN pnpm run build RUN pnpm run build
# --- Stage 3: Продакшен сервер ---
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
EXPOSE 3000
CMD ["npm", "start"]
+22 -7
View File
@@ -31,8 +31,13 @@ export function AuthClient({ dict, lang }: AuthClientProps) {
>("processing"); >("processing");
const [logs, setLogs] = useState<string[]>([]); const [logs, setLogs] = useState<string[]>([]);
const tgContainerRef = useRef<HTMLDivElement>(null); const tgContainerRef = useRef<HTMLDivElement>(null);
const initialized = useRef(false);
const widgetInjected = useRef(false);
useEffect(() => { useEffect(() => {
if (initialized.current) return;
initialized.current = true;
const authenticate = async () => { const authenticate = async () => {
setLogs((prev) => [...prev, `> ${dict.processing}`]); setLogs((prev) => [...prev, `> ${dict.processing}`]);
@@ -42,14 +47,23 @@ export function AuthClient({ dict, lang }: AuthClientProps) {
const hash = window.location.hash; const hash = window.location.hash;
let token = localStorage.getItem("nrxp_token"); let token = localStorage.getItem("nrxp_token");
// Логика получения токена из хеша (переход из Telegram бота) // Логика получения токена из query parameters или хеша
if (hash.includes("token=")) { const searchParams = new URLSearchParams(window.location.search);
const queryToken = searchParams.get("token");
if (queryToken) {
token = queryToken;
searchParams.delete("token");
const newSearch = searchParams.toString();
const newUrl = window.location.pathname + (newSearch ? `?${newSearch}` : "") + window.location.hash;
window.history.replaceState(null, "", newUrl);
} else if (hash.includes("token=")) {
const params = new URLSearchParams(hash.replace("#", "?")); const params = new URLSearchParams(hash.replace("#", "?"));
const urlToken = params.get("token"); const urlToken = params.get("token");
if (urlToken) { if (urlToken) {
token = urlToken; token = urlToken;
// Безопасно очищаем URL от токена // Безопасно очищаем URL от токена, сохраняя search params
window.history.replaceState(null, "", window.location.pathname); window.history.replaceState(null, "", window.location.pathname + window.location.search);
} }
} }
@@ -132,11 +146,12 @@ export function AuthClient({ dict, lang }: AuthClientProps) {
if ( if (
status === "awaiting" && status === "awaiting" &&
tgContainerRef.current && tgContainerRef.current &&
!document.getElementById("tg-widget") !widgetInjected.current
) { ) {
widgetInjected.current = true;
const script = document.createElement("script"); const script = document.createElement("script");
script.id = "tg-widget";
script.src = "https://telegram.org/js/telegram-widget.js?22"; script.src = "https://telegram.org/js/telegram-widget.js?22";
script.async = true;
script.setAttribute( script.setAttribute(
"data-telegram-login", "data-telegram-login",
process.env.NEXT_PUBLIC_BOT_USERNAME || "ntrnr_vpn_bot", process.env.NEXT_PUBLIC_BOT_USERNAME || "ntrnr_vpn_bot",
@@ -240,7 +255,7 @@ export function AuthClient({ dict, lang }: AuthClientProps) {
</p> </p>
{/* При ошибке даем ссылку на телеграм бота для авторизации */} {/* При ошибке даем ссылку на телеграм бота для авторизации */}
<CyberButton <CyberButton
href="https://t.me/ntrnr_vpn_bot" href={`https://t.me/${process.env.NEXT_PUBLIC_BOT_USERNAME || "ntrnr_vpn_bot"}`}
variant="primary" variant="primary"
className="w-full sm:w-auto" className="w-full sm:w-auto"
> >