Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
075a3d4da6 | ||
|
|
ee7be33fa1 | ||
|
|
e6a821ecc3 |
No files matched your search
+3
-2
@@ -41,7 +41,7 @@ LABEL org.opencontainers.image.documentation='https://github.com/gethomepage/hom
|
|||||||
LABEL org.opencontainers.image.source='https://github.com/gethomepage/homepage'
|
LABEL org.opencontainers.image.source='https://github.com/gethomepage/homepage'
|
||||||
LABEL org.opencontainers.image.licenses='Apache-2.0'
|
LABEL org.opencontainers.image.licenses='Apache-2.0'
|
||||||
|
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -56,7 +56,8 @@ COPY --link --chmod=755 docker-entrypoint.sh /usr/local/bin/
|
|||||||
|
|
||||||
RUN apk add --no-cache su-exec
|
RUN apk add --no-cache su-exec
|
||||||
|
|
||||||
ENV PORT 3000
|
ENV HOSTNAME=::
|
||||||
|
ENV PORT=3000
|
||||||
EXPOSE $PORT
|
EXPOSE $PORT
|
||||||
|
|
||||||
HEALTHCHECK --interval=10s --timeout=3s --start-period=20s \
|
HEALTHCHECK --interval=10s --timeout=3s --start-period=20s \
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
export function middleware(req) {
|
||||||
|
// Check the Host header, if HOMEPAGE_ALLOWED_HOSTS is set
|
||||||
|
const host = req.headers.get("host");
|
||||||
|
let allowedHosts = ["localhost:3000"];
|
||||||
|
if (process.env.HOMEPAGE_ALLOWED_HOSTS) {
|
||||||
|
allowedHosts = allowedHosts.concat(process.env.HOMEPAGE_ALLOWED_HOSTS.split(","));
|
||||||
|
}
|
||||||
|
if (!host || !allowedHosts.includes(host)) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(
|
||||||
|
`Host validation failed for: ${host}. Hint: Set HOMEPAGE_ALLOWED_HOSTS to allow requests from this host.`,
|
||||||
|
);
|
||||||
|
return NextResponse.json({ error: "Host validation failed. See logs for more details." }, { status: 400 });
|
||||||
|
}
|
||||||
|
return NextResponse.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
export const config = {
|
||||||
|
matcher: "/api/:path*",
|
||||||
|
};
|
||||||
@@ -86,6 +86,7 @@ function Index({ initialSettings, fallback }) {
|
|||||||
const windowFocused = useWindowFocus();
|
const windowFocused = useWindowFocus();
|
||||||
const [stale, setStale] = useState(false);
|
const [stale, setStale] = useState(false);
|
||||||
const { data: errorsData } = useSWR("/api/validate");
|
const { data: errorsData } = useSWR("/api/validate");
|
||||||
|
const { error: validateError } = errorsData || {};
|
||||||
const { data: hashData, mutate: mutateHash } = useSWR("/api/hash");
|
const { data: hashData, mutate: mutateHash } = useSWR("/api/hash");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -117,6 +118,24 @@ function Index({ initialSettings, fallback }) {
|
|||||||
}
|
}
|
||||||
}, [hashData]);
|
}, [hashData]);
|
||||||
|
|
||||||
|
if (validateError) {
|
||||||
|
return (
|
||||||
|
<div className="w-full h-screen container m-auto justify-center p-10 pointer-events-none">
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<div className="basis-1/2 bg-theme-500 dark:bg-theme-600 text-theme-600 dark:text-theme-300 m-2 rounded-md font-mono shadow-md border-4 border-transparent">
|
||||||
|
<div className="bg-rose-200 text-rose-800 dark:text-rose-200 dark:bg-rose-800 p-2 rounded-md font-bold">
|
||||||
|
<BiError className="float-right w-6 h-6" />
|
||||||
|
Error
|
||||||
|
</div>
|
||||||
|
<div className="p-2 text-theme-100 dark:text-theme-200">
|
||||||
|
<pre className="opacity-50 font-bold pb-2">{validateError}</pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (stale) {
|
if (stale) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center h-screen">
|
<div className="flex items-center justify-center h-screen">
|
||||||
|
|||||||
Reference in new issue
Block a user