One comment we keep getting from people building super interesting fullstack apps is: “I don’t want to have to deal with a CDN when I deploy”.
Fly.io isn’t a CDN, but we do have some CDN-like infrastructure that we can do fun things with. Today’s fun thing is
fly.toml. Add a config section to your app like this:
[[statics]] guest_path = "/app/web/dist" url_prefix = "/static"
When you deploy, we’ll pull
/app/web/dist out of your packaged app, then serve requests that to
https://<app>/static from caches on our edge servers. You don’t have to worry about cache purging or expiration or anything, each deploy just does the right thing. And we keep a few versions around so you don’t get blank pages mid deploy, people who request outdated static URLs will get what they expect.
Requests to static files fall through to your app if they don’t exist, so you can even use this for
/index.html and have your app servers handle
This is not a replacement for Netlify! And if you really need a CDN, it’s not going to solve all your problems (but, like, most people don’t need CDNs). It’s very specifically designed for assets that get deployed alongside full stack Phoenix/Rails/Laravel/Django apps.