fix(uploads): correct UPLOADS_DIR path so image saves work on Render - #25
Merged
Conversation
VITE_USE_MOCK was never set for production builds, so src/main.tsx and src/api/config.ts defaulted to mock mode, meaning the live GH Pages site never reached the real Render backend for login/password-reset.
UPLOADS_DIR used '../../../uploads' from server/src/routes, which assumed a compiled dist/ build. The start/dev scripts run tsx directly against src/, so the path resolved one level too high (repo root instead of server/uploads), a directory that isn't checked into git. On a fresh deploy the directory never existed, so writeFileSync threw and POST /api/user-uploads returned "Failed to save image". Fixed the relative path and added mkdirSync so it self-heals like server/db.ts already does for its data directory.
…ge-rebase # Conflicts: # .env.production
reik
marked this pull request as ready for review
July 5, 2026 19:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UPLOADS_DIRinserver/src/routes/userUploads.tsandgradings.tsused../../../uploads, assuming a compileddist/build directory depth. The server actually runstsxdirectly againstsrc/, so the path resolved to the repo root instead ofserver/uploads— a directory that isn't tracked in git and is never created.writeFileSyncthrows andPOST /api/user-uploadsreturns{"message":"Failed to save image"}, matching the reported live-site error.server/uploads(the directory already git-tracked via.gitkeep), and addedmkdirSync(UPLOADS_DIR, { recursive: true })so it self-heals on any future deploy target — mirroring the patternserver/src/db.tsalready uses for its data directory.Test plan
npm testinserver/— 33/33 passingserver/uploadsvia a standalone script/api/user-uploads— confirmed 201 response and file written to disk; cleaned up the test artifacts afterward