Fix: Use standalone mode for Appwrite Sites (modclean issue)#114
Conversation
Problem: - Appwrite Sites timing out despite environment detection working - Build logs show: "Will use output: DEFAULT (no standalone)" - But modclean removes 7,558 files including the 'next' package - When npm start tries to run 'next start', command not found Root Cause: - Standard Next.js builds require 'next' package at runtime - Appwrite's modclean aggressively removes node_modules - This breaks standard builds but standalone bundles all deps Solution: - Always use output: 'standalone' for ALL deployment modes - Standalone bundles everything into server.js - No external dependencies needed at runtime - Works with Appwrite's modclean cleanup Why Docs Say "Don't Set Output": - Appwrite docs may be outdated or refer to different runtime - In practice, modclean makes standard builds impossible - Standalone is the only reliable option 🤖 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 implements a crucial fix for Next.js applications deployed on Appwrite Sites by enforcing the use of Next.js's 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 correctly identifies and resolves a critical deployment issue on Appwrite Sites by consistently using the Next.js standalone output mode. The analysis of the modclean problem is thorough, and the code change in next.config.ts is the right solution. However, the PR is incomplete because it does not update the project's own deployment documentation (docs/APPWRITE_SITES_DEPLOYMENT.md), which now contains incorrect instructions that will lead to deployment failures. I have added a comment highlighting the necessary documentation update. Once that is addressed, this PR will be a solid improvement.
| // Output mode: Always use standalone | ||
| // Appwrite's modclean removes node_modules including 'next' package | ||
| // So standard builds can't run 'next start' - must use standalone | ||
| output: 'standalone', |
There was a problem hiding this comment.
While this change to enforce output: 'standalone' is the correct fix for the Appwrite deployment issue, this pull request is incomplete as it introduces a discrepancy with the project's deployment documentation. The docs/APPWRITE_SITES_DEPLOYMENT.md file still instructs users to set the Appwrite 'Output Directory' to out, which is incorrect for standalone mode and will cause deployments to fail. The documentation must be updated as part of this change to specify .next/standalone as the output directory to align with this code change.
Problem Diagnosed
After adding debug logging (PR #113), we discovered the real issue:
✅ Environment detection WORKS - correctly identifies Appwrite mode
✅ Build creates standard
.nextoutput as intended❌ Appwrite's
modcleanremoves 7,558 files including thenextpackage❌ When
npm startrunsnext start, the command doesn't exist → timeoutBuild Log Evidence
Root Cause
Standard Next.js builds require the
nextpackage at runtime to executenext start. However:modcleanafter buildingnextpackage fromnode_modulesnext startcommand not found, server never startsStandalone mode bundles everything into
server.jswith zero external dependencies, making it immune to modclean.Solution
Always use
output: 'standalone'for all deployment modes:Why This Works
nextpackagenextConfiguration Changes Required
Appwrite Console (manual update needed):
.next→.next/standaloneWhy Docs Say "Don't Set Output"
Appwrite's documentation states:
However, in practice:
Testing
After this change:
.next/standalone/server.jsnpm startwill execute the self-contained server🤖 Generated with Claude Code