SafetyNet
Section titled “SafetyNet”SafetyNet is the Sherpa.sh zero-risk migration feature that lets you deploy on our platform while keeping your existing provider (Vercel, Netlify, AWS, etc.) as an automatic fallback. Start saving money immediately without the risk of moving everything to a new platform.
Beyond migrations, SafetyNet also serves as a powerful disaster recovery solution. If your primary Sherpa.sh deployment ever experiences issues, traffic automatically fails over to your configured fallback provider without any manual intervention or DNS changes.
How It Works
Section titled “How It Works”SafetyNet uses intelligent edge routing on our CDN to serve traffic from Sherpa.sh by default. If Sherpa.sh ever returns an error, your traffic automatically falls back to your existing deployment - instantly and transparently to your users.
User Request -> Sherpa.sh CDN Edge | V [Sherpa.sh returns success] | V Response served from Sherpa.sh
User Request -> Sherpa.sh CDN Edge | V [Sherpa.sh returns error] | V Automatic fallback to Vercel|Netlify|etc | V Response served from Vercel|Netlify|etc
This approach means you can:
- Start saving immediately as Sherpa.sh handles your traffic at our flat rate
- Reduce your Vercel bill as usage drops
- Keep your existing deployment as a safety net
- Zero downtime risk during the transition
Perfect For
Section titled “Perfect For”SafetyNet is ideal if you are:
- Testing Sherpa.sh with production traffic before fully committing
- Gradually migrating from another platform without downtime risk
- Looking to reduce infrastructure costs immediately
- Wanting to keep your current provider as disaster recovery
Configuration
Section titled “Configuration”Setting up SafetyNet is simple - just enable it from your application settings and configure your fallback URL.
Prerequisites
Section titled “Prerequisites”- An active Sherpa.sh deployment
- Your existing deployment URL (e.g.,
your-app.vercel.app
)
Enabling SafetyNet
Section titled “Enabling SafetyNet”- Navigate to Applications > Your App > SafetyNet in the Sherpa.sh dashboard
- Enable SafetyNet for your application
- Enter your fallback URL (e.g.,
https://your-app.vercel.app
) - Save your configuration
That is it! SafetyNet is now active and will automatically route traffic to your fallback if Sherpa.sh returns an error.
Testing SafetyNet
Section titled “Testing SafetyNet”You can verify that SafetyNet is working correctly by temporarily disabling your Sherpa.sh application:
- Navigate to your application settings page
- Use the toggle in the upper left of the page to disable your application
- Visit your domain - traffic should now be served from your fallback provider
- Re-enable your application using the same toggle
- Visit your domain again - traffic should now be served from Sherpa.sh
When you disable your application, it suspends on the backend, which causes SafetyNet to automatically activate and route all traffic to your configured fallback URL. This is a safe way to test the failover behavior without any actual errors or downtime.
Verifying the SafetyNet is Active
Section titled “Verifying the SafetyNet is Active”You can confirm which provider is serving your traffic using these methods:
Check Response Headers: Inspect the HTTP response headers in your browser's developer tools (Network tab). Look for provider-specific headers:
- Vercel:
x-vercel-id
,x-vercel-cache
- Netlify:
x-nf-request-id
,x-netlify
- Other providers: Check their documentation for identifying headers
Deploy a Visual Change: A foolproof way to test:
- Make a visible change to your application (e.g., add a banner saying "Served from Vercel")
- Deploy this change only to your fallback provider (not to Sherpa.sh)
- Disable your Sherpa.sh application using the toggle
- Visit your domain - you should see the change you deployed to the fallback
- Re-enable Sherpa.sh - the change should disappear as traffic returns to Sherpa.sh
Monitor Fallback Provider Logs: Check the access logs or analytics dashboard of your fallback provider (Vercel, Netlify, etc.) to see incoming requests when SafetyNet is active. This confirms traffic is reaching your fallback infrastructure.
How the Edge Script Works
Section titled “How the Edge Script Works”Behind the scenes, SafetyNet uses an edge script that runs on our Bunny.net-powered CDN infrastructure:
/** * Intercepts origin responses and implements fallback logic */async function onOriginResponse(context: { request: Request, response: Response}): Promise<Response> | Response | void {
// If Sherpa.sh returns an error if (!context.response.ok)) { const originalUrl = new URL(context.request.url);
// Your fallback URL (Vercel, Netlify, etc.) const fallbackHost = 'https://your-app.vercel.app'; const newUrl = `${fallbackHost}${originalUrl.pathname}${originalUrl.search}`;
// Forward the request to your fallback provider const response = await fetch(newUrl, { method: context.request.method, headers: context.request.headers, body: context.request.body, redirect: context.request.redirect, integrity: context.request.integrity, signal: context.request.signal, credentials: context.request.credentials, mode: context.request.mode, referrer: context.request.referrer, referrerPolicy: context.request.referrerPolicy });
return response; }}
How Edge Scripting Works
Section titled “How Edge Scripting Works”SafetyNet leverages edge scripting technology to run code on our CDN, as close as possible to your users. Here is what makes it powerful:
Proximity-Based Execution
Section titled “Proximity-Based Execution”Scripts run on CDN edge nodes across our global network, minimizing latency by executing closer to end users.
V8 Isolate Runtime
Section titled “V8 Isolate Runtime”Edge scripts run inside V8 isolates (the same engine powering Google Chrome), providing efficient and secure execution with fast startup times (sub-millisecond) and strong isolation between requests.
Framework-Agnostic
Section titled “Framework-Agnostic”SafetyNet works with any application framework or technology stack supported by Sherpa.sh:
- Next.js, Remix, Nuxt, SvelteKit, etc
- Docker containers
- Static sites
- Custom applications
What Triggers a Fallback
Section titled “What Triggers a Fallback”SafetyNet automatically routes to your fallback provider when:
- 4xx errors (404, 403, etc.) - Client errors from your Sherpa.sh deployment
- 5xx errors (500, 502, 503, etc.) - Server errors from your Sherpa.sh deployment
- Connection timeouts - If Sherpa.sh does not respond
- Network errors - Any network-level issues
Successful responses (2xx codes, 3xx) are always served from Sherpa.sh.
Performance Characteristics
Section titled “Performance Characteristics”Latency Impact
Section titled “Latency Impact”- Normal operation: No additional latency - traffic routes directly to Sherpa.sh
- Fallback activation: Adds 50-150ms for the intitial fallback request
- Edge decision: Sub-millisecond overhead for the routing logic
Global Availability
Section titled “Global Availability”SafetyNet runs across our 200+ global CDN edge locations, providing:
- Low-latency fallback decisions worldwide
- Regional optimization
- High availability routing
Monitoring Your Migration
Section titled “Monitoring Your Migration”Tracking Fallback Usage
Section titled “Tracking Fallback Usage”You can monitor how often SafetyNet activates your fallback by reviewing:
- CDN access logs in your Sherpa.sh dashboard
- Response times and error rates
- Traffic distribution between Sherpa.sh and your fallback provider
Gradual Cost Reduction
Section titled “Gradual Cost Reduction”As your Sherpa.sh deployment handles more traffic successfully:
- Your fallback provider sees decreasing usage
- Your bills from the fallback provider decrease proportionally
- You can monitor the cost savings in real-time
- Once confident, you can remove the fallback entirely
Disabling SafetyNet
Section titled “Disabling SafetyNet”Once you are confident in your Sherpa.sh deployment, you can disable the safety net in the same place you enabled it. But there is no rush - keep SafetyNet active as long as you need it.
Comparison with Standard Migration
Section titled “Comparison with Standard Migration”Approach | Risk Level | Cost Savings Start | Rollback Speed |
---|---|---|---|
SafetyNet | Minimal | Immediate | Automatic (sub-second) |
Standard Migration | Higher | After full switch | Manual (DNS propagation) |
Technical Details
Section titled “Technical Details”Request Preservation
Section titled “Request Preservation”SafetyNet preserves all aspects of the original request when falling back:
- HTTP method (GET, POST, PUT, DELETE, etc.)
- All request headers (authentication, cookies, user-agent, etc.)
- Request body (for POST/PUT requests)
- Query parameters and search strings
- URL path
- Redirect behavior
- Request integrity
- Request signal
- Credentials
- CORS mode
- Referrer and referrer policy
This ensures your fallback provider receives identical requests, maintaining full compatibility with authentication, form submissions, API calls, and any other request-dependent functionality.
Security Considerations
Section titled “Security Considerations”- Edge scripts run in isolated environments
- No access to sensitive data or credentials
- Cannot modify your Sherpa.sh or fallback deployments
- Audit logs available for compliance
Frequently Asked Questions
Section titled “Frequently Asked Questions”Does SafetyNet increase my costs? No. You only pay the Sherpa.sh flat rate. Your fallback provider bills decrease as Sherpa.sh handles more traffic.
How fast is the fallback? Typically 50-150ms to reroute to your fallback provider. Users experience minimal delay.
Can I use multiple fallback providers? Currently SafetyNet supports one fallback URL per deployment.
Does this work with API routes? Yes. SafetyNet works for all HTTP requests, including API endpoints, static assets, and server-rendered pages.
What if my fallback provider has issues? If both Sherpa.sh and your fallback fail, users see the error from the fallback provider. This is the same behavior as if you were only on the fallback provider.
Can I customize which errors trigger fallback? The default configuration falls back on all error responses. Contact support for custom edge script configurations.
Getting Started
Section titled “Getting Started”Ready to try SafetyNet?
- Deploy your app to Sherpa.sh
- Navigate to Applications > Your App > SafetyNet
- Enable SafetyNet and enter your fallback URL
- Start saving money immediately while your existing deployment remains as backup
Questions? Join us on Discord