Debug: Add logging to diagnose Appwrite environment variable detection#113
Debug: Add logging to diagnose Appwrite environment variable detection#113josiah-nelson wants to merge 2 commits into
Conversation
….js builds Problem: - Appwrite Sites deployment hangs/times out - server never responds - Build succeeds but site is unreachable at https://app.sfplib.com/ - Current start script hardcoded to: node .next/standalone/server.js - This file only exists when using output: 'standalone' in next.config.ts - When deploying without standalone mode, npm start fails silently Root Cause: - Appwrite Sites expects standard Next.js build (per their docs) - Standard builds require 'next start' command - Our script tries to run non-existent standalone server.js - Result: No server process starts, site times out Solution: Detect which build type was created and use appropriate start command: - If .next/standalone/server.js exists → node .next/standalone/server.js - Otherwise → next start This allows the same package.json to work for multiple deployment modes: - Appwrite Sites (standard Next.js SSR) - Docker/Home Assistant (standalone mode) Testing: - Verified with Playwright: site currently times out (no server running) - After fix: npm start will launch appropriate server - Docker/HA builds remain unchanged 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary of ChangesHello @josiah-nelson, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces diagnostic logging to the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces debugging logs to next.config.ts to help diagnose an issue with environment variable detection in Appwrite Sites. The added logs will print the values of relevant environment variables during the build process. Additionally, the start script in package.json is updated to be more robust by checking for the existence of the standalone server file before trying to run it, with a fallback to next start.
My main feedback is regarding the newly added logging. While essential for debugging, it's important to ensure this temporary code is removed after the root cause is identified and fixed to keep the production build logs clean. I've left a specific comment with a suggestion on how to manage this.
| // Debug: Log environment variables during build | ||
| console.log('[next.config.ts] Build-time environment check:'); | ||
| console.log(' APPWRITE_SITE_API_ENDPOINT:', process.env.APPWRITE_SITE_API_ENDPOINT || 'NOT SET'); | ||
| console.log(' APPWRITE_SITE_PROJECT_ID:', process.env.APPWRITE_SITE_PROJECT_ID || 'NOT SET'); | ||
| console.log(' APPWRITE_ENDPOINT:', process.env.APPWRITE_ENDPOINT || 'NOT SET'); | ||
| console.log(' APPWRITE_PROJECT_ID:', process.env.APPWRITE_PROJECT_ID || 'NOT SET'); | ||
| console.log(' DEPLOYMENT_MODE:', process.env.DEPLOYMENT_MODE || 'NOT SET'); |
There was a problem hiding this comment.
While these debug logs (and the ones on lines 47-48) are very helpful for diagnosing the current issue with environment variables, they should be removed once the problem is resolved. Leaving console.log statements in configuration files can lead to noisy build logs in production.
If you anticipate needing this for debugging in the future, consider wrapping all the diagnostic logging in a conditional check based on an environment variable:
if (process.env.DEBUG_CONFIG) {
console.log('[next.config.ts] Build-time environment check:');
console.log(' APPWRITE_SITE_API_ENDPOINT:', process.env.APPWRITE_SITE_API_ENDPOINT || 'NOT SET');
// ... other logs ...
console.log('[next.config.ts] Detected deployment mode:', deploymentMode);
console.log('[next.config.ts] Will use output:', isAppwrite ? 'DEFAULT (no standalone)' : 'standalone');
}This keeps the codebase clean while retaining the debugging utility when needed.
Problem
Appwrite Sites is still timing out even after PR #112 (conditional start command).
Looking at the build logs, the
postbuildscript is running and copying files to.next/standalone/, which means the build is STILL creating standalone output. This indicates the environment variable detection is failing.What This PR Does
Adds debug logging to
next.config.tsto diagnose why environment detection isn't working:Expected Output
When this builds on Appwrite Sites, we should see:
But if detection is failing, we'll see:
Next Steps
This is purely diagnostic - no functionality changes.
🤖 Generated with Claude Code