fix: docker packages and IP parsing for 127.0.0.1
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
.env
|
.env
|
||||||
|
kittyurl-frontend/node_modules
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
# Credit: https://www.digitalocean.com/community/tutorials/how-to-build-a-node-js-application-with-docker
|
# 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
|
FROM node:24-trixie-slim AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY ./kittyurl-frontend/package*.json ./
|
COPY ./kittyurl-frontend/package*.json ./
|
||||||
RUN npm ci && npm cache clean --force
|
RUN npm ci && npm cache clean --force
|
||||||
COPY ./kittyurl-frontend/ .
|
COPY ./kittyurl-frontend/. ./
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM node:24-trixie-slim AS production
|
FROM node:24-trixie-slim AS production
|
||||||
|
|||||||
@@ -11,6 +11,13 @@ export type View = 'home' | 'login' | 'history' | 'jump-game' | 'flappy-game';
|
|||||||
|
|
||||||
const getSubdomain = () => {
|
const getSubdomain = () => {
|
||||||
const hostname = window.location.hostname;
|
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('.');
|
const parts = hostname.split('.');
|
||||||
if (parts.length <= 2) return null;
|
if (parts.length <= 2) return null;
|
||||||
return parts[0];
|
return parts[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user