I’m trying to host a react SPA with Caddy that also has some proxy rewrites for the django API, but I’m getting various errors.
Sometimes it just loads the react app instead of doing the proxy redirect to django.
But currently it’s giving me ERR_TOO_MANY_REDIRECTS for any page.
What should happen:
- /admin, /api, and /staticfiles should proxy to the hostname django.
- All other URLs should redirect to index.html so it can be handled by react-router.
# Main site
example.com {
gzip
log stdout
errors stdout
root /app/frontend
proxy /staticfiles django:8000 {
transparent
}
proxy /api django:8000 {
transparent
}
proxy /admin django:8000 {
transparent
}
rewrite {
to .* /index.html
}
}