This has been my first time attempting to deploy an app on fly.io (well, I have been attempting to do this for over a week and, to be honest, I haven’t deployed a personal app in maybe 10 years so I’m sure things have changed). I tried to deploy my frontend and backend together but, even after asking several questions in this community, I haven’t quite gotten it to work. I’ve seen articles recommending against SPA apps on fly.io. I’ve seen people recommend deploying the frontend and backend separately. I guess, I’m getting a little burnt out trying to figure out how to deploy this app and could use some advice. Maybe fly.io just isn’t the right PaaS for me.
Without more details, it is hard to provide actionable advice.
Normally the way SPA apps work in development is that there is a separate server for the front end and back end.
Normally the way SPA apps work in production is that there is a build step that converts the front end into static files that are served by the back end, and there is only a single server running.
I’d add another option on top of @rubys’ excellent advice.
SPAs sometimes run locally (in development) on two ports, one for each of the frontend and backend web servers. However in production this can be problematic, because you only want to use 443 (HTTPS). This would then create a clash, since you can’t have two servers attaching to the same domain and same port.
To solve this, you can have three machines: a front end, a back end, and a proxy that detects and forwards front/back traffic to the right place. Traefik does this; I used it about ten years ago, and it was very good. I believe it is still actively maintained.
My solution is a bit more involved than Sam’s solution, but it has the benefit that you can get it to work in Docker Compose locally, so you can prove it works before shifting it to Fly.
I would probably go for Sam’s idea first, and swap to mine if you want a boss-level challenge
Finally, there a bunch of employees and customers here who can help with high-detail questions. If you can give us a solid overview of your app, your config, your systems diagram etc. then someone may be able to show you want you need to do. You can of course hop to Render, Vultr, Digital Ocean, or AWS, but I fear that you’ll end up in the same YAML pickle! As much as these platforms try to simplify architecture, architecture is still hard.
I know this topic is how to deploy an app to Fly, but I had this same question last year for Heroku, and I wonder if my writeup might give you some guidance.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.