From c829cb2a6bf2fcb6da999a3bd7a66ad98fe9eb92 Mon Sep 17 00:00:00 2001 From: sherl Date: Fri, 9 Jan 2026 21:55:46 +0100 Subject: [PATCH] fix: docker packages and IP parsing for 127.0.0.1 --- .dockerignore | 3 ++- Dockerfile | 3 ++- kittyurl-frontend/src/App.tsx | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index 2eea525..cead363 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ -.env \ No newline at end of file +.env +kittyurl-frontend/node_modules \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index be9eb65..94cac4f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,12 @@ # Credit: https://www.digitalocean.com/community/tutorials/how-to-build-a-node-js-application-with-docker +# https://stackoverflow.com/a/56941391 FROM node:24-trixie-slim AS builder WORKDIR /app COPY ./kittyurl-frontend/package*.json ./ RUN npm ci && npm cache clean --force -COPY ./kittyurl-frontend/ . +COPY ./kittyurl-frontend/. ./ RUN npm run build FROM node:24-trixie-slim AS production diff --git a/kittyurl-frontend/src/App.tsx b/kittyurl-frontend/src/App.tsx index cf9e146..e2f98b8 100644 --- a/kittyurl-frontend/src/App.tsx +++ b/kittyurl-frontend/src/App.tsx @@ -11,6 +11,13 @@ export type View = 'home' | 'login' | 'history' | 'jump-game' | 'flappy-game'; const getSubdomain = () => { const hostname = window.location.hostname; + // Handle localhost and 127.0.0.1 cases. + // For more advanced cases (like bare IP hosting) + // a regex may be necessary. + if (hostname === 'localhost' || hostname === '127.0.0.1') { + return null; + } + const parts = hostname.split('.'); if (parts.length <= 2) return null; return parts[0];