Spaces:
Running
Running
fix: redirect bare paths to /app/ and disable image optimization
Browse filesPost-login 404: Postiz navigates to /launches (no basePath prefix) after
auth; health-server now redirects any unrecognized path to /app<path>
instead of 404-ing.
_next/image 400s: disable Next.js image optimization (unoptimized:true in
next.config.js) so <Image> renders plain <img src="/app/auth/avatars/...">
tags that route through nginx correctly, bypassing the optimizer's internal
fetch which failed because static files live at the basePath-prefixed path.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Dockerfile +10 -0
- health-server.js +6 -3
Dockerfile
CHANGED
|
@@ -63,6 +63,16 @@ RUN sed -i "s|const nextConfig = {|const nextConfig = {\n basePath: '/app',\n
|
|
| 63 |
&& grep -q "swcMinify: false" apps/frontend/next.config.js \
|
| 64 |
&& grep -q "cpus: 1" apps/frontend/next.config.js \
|
| 65 |
|| (echo "PATCH FAILED β next.config.js shape changed upstream"; exit 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
ENV SENTRY_DSN="" \
|
| 68 |
SENTRY_AUTH_TOKEN="" \
|
|
|
|
| 63 |
&& grep -q "swcMinify: false" apps/frontend/next.config.js \
|
| 64 |
&& grep -q "cpus: 1" apps/frontend/next.config.js \
|
| 65 |
|| (echo "PATCH FAILED β next.config.js shape changed upstream"; exit 1)
|
| 66 |
+
# Patch: disable Next.js image optimisation.
|
| 67 |
+
# With basePath="/app", the _next/image optimizer fetches static files from
|
| 68 |
+
# Next.js's internal URL without the basePath prefix, causing 400 errors.
|
| 69 |
+
# unoptimized:true makes <Image> render as plain <img> tags; the browser
|
| 70 |
+
# fetches /app/auth/avatars/β¦ which routes correctly through nginx.
|
| 71 |
+
# If Postiz already has an images:{} block, inject unoptimized inside it;
|
| 72 |
+
# otherwise add a new images block at the top of nextConfig.
|
| 73 |
+
RUN grep -q 'images:' apps/frontend/next.config.js \
|
| 74 |
+
&& sed -i 's|images: {|images: {\n unoptimized: true,|' apps/frontend/next.config.js \
|
| 75 |
+
|| sed -i "s|const nextConfig = {|const nextConfig = {\n images: { unoptimized: true },|" apps/frontend/next.config.js
|
| 76 |
|
| 77 |
ENV SENTRY_DSN="" \
|
| 78 |
SENTRY_AUTH_TOKEN="" \
|
health-server.js
CHANGED
|
@@ -858,9 +858,12 @@ const server = http.createServer((req, res) => {
|
|
| 858 |
return;
|
| 859 |
}
|
| 860 |
|
| 861 |
-
// ββ Anything else β
|
| 862 |
-
|
| 863 |
-
|
|
|
|
|
|
|
|
|
|
| 864 |
});
|
| 865 |
|
| 866 |
server.on("upgrade", (req, socket, head) => {
|
|
|
|
| 858 |
return;
|
| 859 |
}
|
| 860 |
|
| 861 |
+
// ββ Anything else β redirect to /app<path> ββββββββββββββββββββββββββββββ
|
| 862 |
+
// After login, Postiz's client-side router may navigate to a path without
|
| 863 |
+
// the /app basePath prefix (e.g. /launches, /analytics, /api/...).
|
| 864 |
+
// Redirect those here rather than 404-ing so the browser lands correctly.
|
| 865 |
+
res.writeHead(302, { Location: "/app" + pathname + (parsedUrl.search || "") });
|
| 866 |
+
res.end();
|
| 867 |
});
|
| 868 |
|
| 869 |
server.on("upgrade", (req, socket, head) => {
|