How to serve a SPA using [[statics]] section?

I’m trying to deploy an app in which there is an API, and a front SPA. I want the front SPA to be served by fly.io without reaching my own server, for performance reason.

In my fly.toml file:

[[statics]]
guest_path = "/home/myapp/front/dist"
url_prefix = "/"

After deploying, I logged into my VM using SSH and run:

> ls /home/myapp/front/dist

assets  index.html

which shows my SPA is built and ready to be served.
However, when I try to access my website, at the root level, I get a 404 error.

What did I get wrong? Thanks!

1 Like

Hey - which region are you deploying to?

ams(B) when I run flyctl status.
I aim to deploy at cdg in the end.

Any update on this? I might have a similar issue.

[[statics]] blocks don’t automatically rewrite to index.html iirc

Correct! Your root path has to be served from inside your app. (for what it’s worth, I believe that you should be able to directly request /index.html if you want to test things)