Notification Emails Contain Broken Links in Bolt App
Users receive notification emails from your Bolt.new application (order confirmations, status updates, invitation links), but when they click the links, they land on 404 pages, localhost URLs, or completely wrong pages. The emails are being delivered but every link inside them is broken.
This destroys user trust immediately. A customer who receives an order confirmation with a broken tracking link, or a team member who gets an invitation email that leads to a 404, will question whether your entire application is legitimate. Broken email links are one of the most visible and damaging bugs.
The root cause is almost always that the URLs in email templates are hardcoded to your development environment or constructed incorrectly. Email templates are generated once and don't automatically update when your app URL changes from development to production.
Error Messages You Might See
Common Causes
- Hardcoded localhost URLs — Email templates contain links like http://localhost:3000/orders/123 instead of using the production domain
- Missing base URL environment variable — No APP_URL or NEXT_PUBLIC_SITE_URL configured, so link generation defaults to localhost
- Dynamic route segments wrong — Links to /orders/[id] are rendered literally as /orders/[id] instead of /orders/abc123 with the actual ID
- URL encoding issues — Special characters in query parameters or paths are not properly encoded, breaking the link
- Trailing slash mismatch — Links include or exclude trailing slashes inconsistently, causing routing failures on the frontend
How to Fix It
- Set a base URL environment variable — Define APP_URL=https://yourapp.com in your environment and use it for all email link generation: const link = `${process.env.APP_URL}/orders/${orderId}`
- Create an email URL helper — Build a utility function: function emailUrl(path: string) { return new URL(path, process.env.APP_URL).toString(); } and use it everywhere in email templates
- Test emails with real link clicking — Don't just check that emails arrive - click every single link in your test emails to verify they resolve correctly
- Use absolute URLs always — Never use relative paths in emails (/orders/123). Always use full absolute URLs (https://yourapp.com/orders/123)
- Add link tracking — Use UTM parameters on email links so you can track click-through rates and quickly identify which links are broken
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
How do I make email links work in both development and production?
Use an environment variable for your base URL (APP_URL=http://localhost:3000 in dev, APP_URL=https://yourapp.com in production). Build all email links using this variable instead of hardcoding any domain.
How can I preview email templates before sending?
Create a preview route like /api/email-preview/order-confirmation that renders the email HTML in the browser. This lets you check formatting, links, and dynamic content without actually sending emails.