Spaces:
Running
Running
debug: log X OAuth callback params (oauth_verifier presence check)
Browse files- health-server.js +24 -0
health-server.js
CHANGED
|
@@ -1829,9 +1829,16 @@ const server = http.createServer((req, res) => {
|
|
| 1829 |
? fs.readFileSync("/tmp/huggingpost-cloudflare-proxy.env", "utf8")
|
| 1830 |
: "No proxy env";
|
| 1831 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1832 |
const out = [
|
| 1833 |
credSection,
|
| 1834 |
"",
|
|
|
|
|
|
|
|
|
|
| 1835 |
"=== BACKEND ERROR LOG (last 150 lines) ===",
|
| 1836 |
errLog,
|
| 1837 |
"",
|
|
@@ -1927,6 +1934,23 @@ const server = http.createServer((req, res) => {
|
|
| 1927 |
// After login, Postiz's client-side router may navigate to a path without
|
| 1928 |
// the /app basePath prefix (e.g. /launches, /analytics, /api/...).
|
| 1929 |
// Redirect those here rather than 404-ing so the browser lands correctly.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1930 |
res.writeHead(302, {
|
| 1931 |
Location: "/app" + pathname + (parsedUrl.search || ""),
|
| 1932 |
});
|
|
|
|
| 1829 |
? fs.readFileSync("/tmp/huggingpost-cloudflare-proxy.env", "utf8")
|
| 1830 |
: "No proxy env";
|
| 1831 |
|
| 1832 |
+
const xCallbackLog = fs.existsSync("/tmp/x-oauth-callbacks.log")
|
| 1833 |
+
? fs.readFileSync("/tmp/x-oauth-callbacks.log", "utf8")
|
| 1834 |
+
: "(no X callbacks recorded yet β try adding X channel now)";
|
| 1835 |
+
|
| 1836 |
const out = [
|
| 1837 |
credSection,
|
| 1838 |
"",
|
| 1839 |
+
"=== X OAUTH CALLBACKS (from health-server) ===",
|
| 1840 |
+
xCallbackLog,
|
| 1841 |
+
"",
|
| 1842 |
"=== BACKEND ERROR LOG (last 150 lines) ===",
|
| 1843 |
errLog,
|
| 1844 |
"",
|
|
|
|
| 1934 |
// After login, Postiz's client-side router may navigate to a path without
|
| 1935 |
// the /app basePath prefix (e.g. /launches, /analytics, /api/...).
|
| 1936 |
// Redirect those here rather than 404-ing so the browser lands correctly.
|
| 1937 |
+
|
| 1938 |
+
// Log OAuth callbacks for debugging.
|
| 1939 |
+
if (pathname === "/integrations/social/x") {
|
| 1940 |
+
const oauthToken = parsedUrl.searchParams.get("oauth_token") || "(missing)";
|
| 1941 |
+
const oauthVerifier = parsedUrl.searchParams.get("oauth_verifier") || "(MISSING!)";
|
| 1942 |
+
const denied = parsedUrl.searchParams.get("denied");
|
| 1943 |
+
const ts = new Date().toISOString();
|
| 1944 |
+
const msg = denied
|
| 1945 |
+
? `[${ts}] X OAuth DENIED β denied=${denied}`
|
| 1946 |
+
: `[${ts}] X OAuth callback β oauth_token=${oauthToken.slice(0,20)}... oauth_verifier=${oauthVerifier === "(MISSING!)" ? "(MISSING! β X did not send verifier)" : oauthVerifier.slice(0,10) + "... (present β)"}`;
|
| 1947 |
+
console.log(msg);
|
| 1948 |
+
// Append to a file the debug-logs endpoint can read.
|
| 1949 |
+
try {
|
| 1950 |
+
fs.appendFileSync("/tmp/x-oauth-callbacks.log", msg + "\n");
|
| 1951 |
+
} catch(_) {}
|
| 1952 |
+
}
|
| 1953 |
+
|
| 1954 |
res.writeHead(302, {
|
| 1955 |
Location: "/app" + pathname + (parsedUrl.search || ""),
|
| 1956 |
});
|