Fix form submissions and image loading by disabling static export for VPS deployment#233
Conversation
… VPS deployment Co-authored-by: syed-reza98 <71028588+syed-reza98@users.noreply.github.com>
|
@copilot Web3forms signup with codestromhub@gmail.com The repository secret has been updated NEXT_PUBLIC_WEB3FORMS_KEY for Web3forms access key All the emails sent from codestromhub@gmail.com and in cc add the mail arvincia@sparrow-group.com |
…om with arvincia@sparrow-group.com in CC Co-authored-by: syed-reza98 <71028588+syed-reza98@users.noreply.github.com>
Updated Web3Forms configuration in commit 10f9e48:
The |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes critical production issues where form submissions were failing and images weren't loading by making the static export configuration conditional based on deployment target. The root cause was that the application was always configured for static export, which prevented server-side features like API routes from working on VPS deployment.
- Made static export conditional only for GitHub Pages deployment
- Fixed environment detection logic for proper API route usage in production
- Updated Web3Forms email routing to send notifications to the correct addresses
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| client/next.config.ts | Made static export conditional based on DEPLOY_TARGET environment variable, enabling server-side features for VPS deployment |
| client/src/lib/serverless-forms.ts | Fixed environment detection logic and updated Web3Forms email routing to send notifications to codestromhub@gmail.com |
| // Include submitter's email in the message content | ||
| formData.append('Submitter Email', userEmail); |
There was a problem hiding this comment.
Using 'Submitter Email' as a field name may cause issues with Web3Forms processing. Form field names should typically use lowercase with underscores or hyphens (e.g., 'submitter_email' or 'user-email') to ensure consistent processing by email services.
| // Include submitter's email in the message content | ||
| formData.append('Submitter Email', userEmail); |
There was a problem hiding this comment.
Using 'Submitter Email' as a field name may cause issues with Web3Forms processing. Form field names should typically use lowercase with underscores or hyphens (e.g., 'submitter_email' or 'user-email') to ensure consistent processing by email services.
Problem
The production site was experiencing critical issues where both the Contact and RSVP forms failed to submit, and images were not loading in the gallery and homepage sections. Users received error messages:
Root Cause
The application was configured with
output: 'export'innext.config.tsfor static GitHub Pages deployment. This configuration forced a static HTML export which is fundamentally incompatible with:/api/contact,/api/rsvp/form)When deployed to a VPS with server capabilities, the static export configuration prevented all server-side features from working, causing the forms to fail and images to not load.
Solution
Made the static export configuration conditional based on the deployment target:
1. Updated
next.config.ts2. Updated
src/lib/serverless-forms.tsFixed the environment detection logic to properly use API routes in production:
Web3Forms Email Configuration: Updated the Web3Forms integration to correctly route email notifications:
codestromhub@gmail.comarvincia@sparrow-group.comon all form submissionscodestromhub@gmail.comImpact
✅ Contact Form
/api/contactendpoint✅ RSVP Form
/api/rsvp/formendpoint✅ Gallery & Images
/api/mediaendpoint/api/media/static/[...filename]routeScreenshots
Gallery page with images loading correctly:
RSVP form submission success:
Testing
Deployment
For VPS/Production (current setup):
No configuration changes needed. The application automatically uses server-side features:
For GitHub Pages (alternative/future):
Set the deployment target environment variable:
The repository secret
NEXT_PUBLIC_WEB3FORMS_KEYis configured and will be used automatically in static mode.Files Changed
client/next.config.ts- Made static export conditional for deployment flexibilityclient/src/lib/serverless-forms.ts- Fixed environment detection logic and Web3Forms email routingAll form submission and image loading issues are now resolved for production VPS deployment! 🎉
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.