somratpro commited on
Commit
3d8fd70
ยท
1 Parent(s): 2869840

fix: adjust OAuth callback paths, force /app root redirect, and increase logging verbosity for sync processes

Browse files
Files changed (3) hide show
  1. health-server.js +12 -4
  2. postiz-sync.py +3 -3
  3. start.sh +2 -1
health-server.js CHANGED
@@ -101,7 +101,7 @@ function getSocialPlatforms() {
101
  // Returns detailed per-platform OAuth setup guide data.
102
  // publicUrl: "https://somratpro-huggingpost.hf.space" (no trailing slash)
103
  function getOAuthPlatformDetails(publicUrl) {
104
- const cb = (provider) => `${publicUrl}/app/integrations/social/${provider}`;
105
  const e = process.env;
106
  return [
107
  {
@@ -1078,9 +1078,17 @@ const server = http.createServer((req, res) => {
1078
  }
1079
 
1080
  // โ”€โ”€ /app, /app/ and /app/* โ†’ proxy to nginx (Next.js handles routing) โ”€โ”€โ”€โ”€
1081
- // Do NOT short-circuit /app/ to /app/auth/ here โ€” Next.js middleware does
1082
- // the right thing: auth cookie present โ†’ /launches, absent โ†’ /auth/.
1083
- if (pathname === "/app" || pathname.startsWith("/app/")) {
 
 
 
 
 
 
 
 
1084
  const stripped = pathname.slice("/app".length) || "/";
1085
  const query = parsedUrl.search || "";
1086
 
 
101
  // Returns detailed per-platform OAuth setup guide data.
102
  // publicUrl: "https://somratpro-huggingpost.hf.space" (no trailing slash)
103
  function getOAuthPlatformDetails(publicUrl) {
104
+ const cb = (provider) => `${publicUrl}/integrations/social/${provider}`;
105
  const e = process.env;
106
  return [
107
  {
 
1078
  }
1079
 
1080
  // โ”€โ”€ /app, /app/ and /app/* โ†’ proxy to nginx (Next.js handles routing) โ”€โ”€โ”€โ”€
1081
+ if (pathname === "/app" || pathname === "/app/") {
1082
+ // Postiz Next.js root redirect to /launches sometimes fails with basePath
1083
+ // + trailingSlash:true, leaving users on a blank /app/ page after signup.
1084
+ // Force the redirect here. Next.js middleware will still redirect to
1085
+ // /auth/login if they aren't authenticated yet.
1086
+ res.writeHead(302, { Location: "/app/launches/" + (parsedUrl.search || "") });
1087
+ res.end();
1088
+ return;
1089
+ }
1090
+
1091
+ if (pathname.startsWith("/app/")) {
1092
  const stripped = pathname.slice("/app".length) || "/";
1093
  const query = parsedUrl.search || "";
1094
 
postiz-sync.py CHANGED
@@ -132,7 +132,7 @@ def backup_database() -> tuple[str | None, bool]:
132
  logger.error(f"pg_dump failed: {result.stderr.decode('utf-8', errors='ignore')}")
133
  return None, False
134
  size_mb = dump_file.stat().st_size / 1024 / 1024
135
- logger.debug(f"Database dumped ({size_mb:.2f} MB)")
136
  return str(dump_file), True
137
  except subprocess.TimeoutExpired:
138
  logger.error("pg_dump timed out (>600s)")
@@ -170,7 +170,7 @@ def create_backup_tarball(dump_file: str) -> tuple[str | None, bool]:
170
  _write_tarball(tarball, dump_file, include_next=True)
171
  size = tarball.stat().st_size
172
  size_mb = size / 1024 / 1024
173
- logger.debug(f"Tarball created ({size_mb:.2f} MB)")
174
  if size > SYNC_MAX_FILE_BYTES:
175
  logger.warning(
176
  f"Tarball with .next too large ({size_mb:.0f} MB > "
@@ -182,7 +182,7 @@ def create_backup_tarball(dump_file: str) -> tuple[str | None, bool]:
182
  _write_tarball(tarball, dump_file, include_next=False)
183
  size = tarball.stat().st_size
184
  size_mb = size / 1024 / 1024
185
- logger.debug(f"Tarball without .next: {size_mb:.2f} MB")
186
  if size > SYNC_MAX_FILE_BYTES:
187
  logger.error(
188
  f"Backup still too large without .next ({size_mb:.0f} MB > "
 
132
  logger.error(f"pg_dump failed: {result.stderr.decode('utf-8', errors='ignore')}")
133
  return None, False
134
  size_mb = dump_file.stat().st_size / 1024 / 1024
135
+ logger.info(f"Database dumped ({size_mb:.2f} MB)")
136
  return str(dump_file), True
137
  except subprocess.TimeoutExpired:
138
  logger.error("pg_dump timed out (>600s)")
 
170
  _write_tarball(tarball, dump_file, include_next=True)
171
  size = tarball.stat().st_size
172
  size_mb = size / 1024 / 1024
173
+ logger.info(f"Tarball created ({size_mb:.2f} MB)")
174
  if size > SYNC_MAX_FILE_BYTES:
175
  logger.warning(
176
  f"Tarball with .next too large ({size_mb:.0f} MB > "
 
182
  _write_tarball(tarball, dump_file, include_next=False)
183
  size = tarball.stat().st_size
184
  size_mb = size / 1024 / 1024
185
+ logger.info(f"Tarball without .next: {size_mb:.2f} MB")
186
  if size > SYNC_MAX_FILE_BYTES:
187
  logger.error(
188
  f"Backup still too large without .next ({size_mb:.0f} MB > "
start.sh CHANGED
@@ -248,9 +248,10 @@ fi
248
  SYNC_PID=""
249
  if [ -n "${HF_TOKEN:-}" ]; then
250
  (
 
251
  while true; do
252
- sleep "$SYNC_INTERVAL"
253
  python3 /opt/postiz-sync.py sync 2>&1 || true
 
254
  done
255
  ) &
256
  SYNC_PID=$!
 
248
  SYNC_PID=""
249
  if [ -n "${HF_TOKEN:-}" ]; then
250
  (
251
+ sleep 60 # Initial backup 60s after boot to save setup (signup, keys)
252
  while true; do
 
253
  python3 /opt/postiz-sync.py sync 2>&1 || true
254
+ sleep "$SYNC_INTERVAL"
255
  done
256
  ) &
257
  SYNC_PID=$!