This document outlines the strategy for migrating users from the old domain (stm.jermainesizemore.com) to the new domain (tm.jermainesizemore.com) while handling cached PWA installations.
- Cache Version Bumped:
v1→v2to force cache invalidation - Domain Migration Detection: Added logic to detect old domain and notify users
- Message Posting: Service worker sends migration messages to clients on old domain
- Auto-redirect: Users on old domain are automatically redirected after 3 seconds
- PWA Detection: Detects if app is running as installed PWA
- Toast Notification: Shows friendly migration message to users
- LocalStorage Tracking: Remembers which domain the PWA was installed from
- Environment Variables: Updated
.envwith new domain - Manifest: Updated
related_applicationsURL - SEO Files: Updated all fallback URLs in
sitemap.ts,robots.ts,seo.ts - Next.js Config: Added custom header to indicate migration
- Added
<DomainMigrationHandler />component to notify and redirect users
Most Effective for All Users
Configure your hosting provider to redirect all traffic from old → new domain:
# Example for Nginx
server {
server_name stm.jermainesizemore.com;
return 301 https://tm.jermainesizemore.com$request_uri;
}# Example for Apache
RewriteEngine On
RewriteCond %{HTTP_HOST} ^stm\.jermainesizemore\.com$ [NC]
RewriteRule ^(.*)$ https://tm.jermainesizemore.com/$1 [R=301,L]For Vercel/Netlify:
- Add both domains to your project
- Set
tm.jermainesizemore.comas primary - Configure old domain to redirect (usually in dashboard settings)
Automatic via DomainMigrationHandler
The app now automatically:
- Detects when user is on old domain
- Shows toast notification
- Redirects to new domain after 3 seconds
- Preserves the current path and query parameters
For Installed PWAs
When a PWA installed from old domain loads:
- Service worker detects old domain
- Sends message to client
- Client shows migration notice
- User is guided to reinstall from new domain
Already Implemented
All URLs in the app now use:
process.env.NEXT_PUBLIC_BASE_URL(primary)https://tm.jermainesizemore.com(fallback)
- Update Spotify OAuth redirect URI in Spotify Developer Dashboard
- Old:
https://stm.jermainesizemore.com/api/auth/callback/spotify - New:
https://tm.jermainesizemore.com/api/auth/callback/spotify - KEEP BOTH during migration period
- Old:
- Set environment variables in production:
NEXTAUTH_URL=https://tm.jermainesizemore.com NEXT_PUBLIC_BASE_URL=https://tm.jermainesizemore.com - Configure DNS for new domain
- Set up SSL certificate for new domain
- Deploy app to new domain first
- Test thoroughly on new domain
- Keep old domain active with redirect for 30-90 days
- Monitor analytics for traffic patterns
- Update all external links to new domain
- Update social media profiles
- Update any documentation/READMEs
- Submit new domain to Google Search Console
- Update sitemap in Google Search Console
- Monitor for broken links or 404s
- Automatic redirect (3-second delay with notice)
- No action required
Users with installed PWA from old domain need to:
- Uninstall old PWA from their device
- Visit new domain:
https://tm.jermainesizemore.com - Reinstall PWA from new domain
Consider announcing the migration via:
- In-app banner/toast (✅ implemented)
- Email to registered users
- Social media announcement
- Blog post about the change
- New users on new domain ✓
- Should work normally
- Existing users visiting old domain
- Should see redirect notice
- Should be redirected to new domain
- PWA installed from old domain
- Should see migration notice
- Should be prompted to reinstall
- PWA installed from new domain
- Should work normally
- No migration notices
# Build and test locally
pnpm build
pnpm start
# Test with different hostnames (modify /etc/hosts if needed)
# Add to /etc/hosts:
# 127.0.0.1 tm.jermainesizemore.local
# 127.0.0.1 stm.jermainesizemore.local- Deploy to new domain
- Keep both domains active
- Monitor for issues
- Both domains active with redirect
- Active user communication
- Monitor analytics
- Old domain redirects permanently
- Can eventually sunset old domain
- Keep redirect active for at least 6-12 months for SEO
If issues arise:
- Revert environment variables to old domain
- Deploy previous version
- Keep new domain as alias/redirect
- Investigate issues before re-attempting
Track these metrics:
- 301 redirect count (old → new domain)
- 404 errors on new domain
- User session continuity
- OAuth callback success rate
- PWA installation rate on new domain
If users encounter issues:
- Clear browser cache and cookies
- Uninstall and reinstall PWA
- Check OAuth connection status
- Re-authenticate with Spotify if needed
- 301 redirects preserve ~90-99% of SEO value
- Google typically processes domain changes within 2-4 weeks
- Keep old domain redirecting for at least 6 months
- NextAuth session cookies are domain-specific
- Users will need to re-authenticate on new domain
- This is expected behavior and handled automatically
- Each domain has its own PWA installation
- Users must reinstall from new domain
- No automatic migration for installed PWAs (browser limitation)
Old Domain: stm.jermainesizemore.com
New Domain: tm.jermainesizemore.com
Migration Status: Ready for deployment
User Impact: Minimal (automatic redirect)
Downtime: None expected