Overview
Path Routing lets you serve Anymorph pages from specific paths (like /a/*) while keeping your existing site intact. No DNS changes required.
yourdomain.com/a/* → Anymorph pages
yourdomain.com/* → Your existing site
Prerequisites
- Your workspace slug from Anymorph Dashboard
- Your proxy URL:
https://{slug}.proxy.anymorph.app
Vercel
Netlify
Cloudflare Pages
AWS CloudFront
Nginx
Other
Add rewrites to your vercel.json:{
"rewrites": [
{
"source": "/a/:path*",
"destination": "https://your-slug.proxy.anymorph.app/a/:path*"
}
]
}
Replace your-slug with your workspace slug, then deploy.
{
"rewrites": [
{
"source": "/api/:path*",
"destination": "https://api.example.com/:path*"
},
{
"source": "/a/:path*",
"destination": "https://your-slug.proxy.anymorph.app/a/:path*"
}
]
}
{
"rewrites": [...],
"headers": [
{
"source": "/a/:path*",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=3600, stale-while-revalidate=86400"
}
]
}
]
}
Add to your netlify.toml:[[redirects]]
from = "/a/*"
to = "https://your-slug.proxy.anymorph.app/a/:splat"
status = 200
force = true
Or use _redirects file:/a/* https://your-slug.proxy.anymorph.app/a/:splat 200
Add to your _redirects file:/a/* https://your-slug.proxy.anymorph.app/a/:splat 200
Or use a Cloudflare Worker for more control:export default {
async fetch(request) {
const url = new URL(request.url);
if (url.pathname.startsWith('/a/')) {
const proxyUrl = new URL(url.pathname + url.search,
'https://your-slug.proxy.anymorph.app');
return fetch(proxyUrl.toString());
}
return fetch(request);
}
};
1. Add Anymorph as an origin:
- Origin domain:
your-slug.proxy.anymorph.app
- Protocol: HTTPS only
2. Create cache behavior:
- Path pattern:
/a/*
- Origin: Select the Anymorph origin
- Cache policy:
CachingOptimized
location /a/ {
proxy_pass https://your-slug.proxy.anymorph.app;
proxy_ssl_server_name on;
proxy_set_header Host your-slug.proxy.anymorph.app;
}
proxy_cache_path /var/cache/nginx/anymorph
levels=1:2 keys_zone=anymorph_cache:10m max_size=100m;
location /a/ {
proxy_cache anymorph_cache;
proxy_cache_valid 200 1h;
proxy_cache_use_stale error timeout http_502 http_503;
proxy_pass https://your-slug.proxy.anymorph.app;
proxy_ssl_server_name on;
proxy_set_header Host your-slug.proxy.anymorph.app;
}
Configure your reverse proxy to forward /a/* to:https://your-slug.proxy.anymorph.app/a/...
Apache:<Location "/a/">
ProxyPass "https://your-slug.proxy.anymorph.app/a/"
ProxyPassReverse "https://your-slug.proxy.anymorph.app/a/"
RequestHeader set Host "your-slug.proxy.anymorph.app"
</Location>
Caddy:handle /a/* {
reverse_proxy https://your-slug.proxy.anymorph.app {
header_up Host your-slug.proxy.anymorph.app
}
}
Traefik:http:
routers:
anymorph:
rule: "PathPrefix(`/a`)"
service: anymorph
services:
anymorph:
loadBalancer:
servers:
- url: "https://your-slug.proxy.anymorph.app"
Testing
After setup, test your connection using the /__check__ endpoint:
curl https://yourdomain.com/a/__check__
Success response:
{"status": "connected", "domain": "yourdomain.com"}
Failure response:
{"status": "not_configured", "message": "Domain not found in proxy configuration"}
/__check__ only verifies the proxy connection. To confirm pages are deployed, visit the actual page path.
Custom Path Prefix
You can use any path prefix. Just update the source pattern:
{
"rewrites": [
{
"source": "/compare/:path*",
"destination": "https://your-slug.proxy.anymorph.app/a/:path*"
}
]
}
Now yourdomain.com/compare/x-vs-y maps to your Anymorph page.
Troubleshooting
404 Error: Subdomain not configured
Your workspace slug is incorrect. Check the Anymorph Dashboard.
- Verify the config file is in the correct location
- Check for syntax errors
- Redeploy after making changes
First requests may be slower. Enable caching for better performance.
Ensure your proxy configuration includes:
proxy_ssl_server_name on (Nginx)
- HTTPS-only origin protocol (CloudFront)