default path issue with static files with Suave, in F#

93 Views Asked by At

I am not understanding the doc when it comes to serving static files.

I have a site where the backend is deployed to /app in a docker container and the front end part is deployed to /app/frontend

The main file for the front end is at: /app/frontend/index.html

In the config I have this:

homeFolder = Some "/app/frontend"

and then:

GET >=> choose
    [
        path "/healthcheck" >=> Successful.OK "ok"
        pathScan "/checkqr/%s" checkQRCode
        path "/" >=> Files.file "index.html"
        Files.browseHome
    ]

when I go to domain.com I get a 404 but when I go to domain.com/index.html I get the index.

what did I miss with the syntax? I would like to serve the index.html file when going to domain.com


Tests done in the meantime:

path "/" >=> Files.browse "index.html"
path "/" >=> Files.file "index.html"
path "/" >=> Files.browseFile "/app/frontend" "index.html"
path "/" >=> Files.browseFile "frontend" "index.html"
path "/" >=> Files.sendFile "index.html" true
path "/" >=> Files.file (Files.resolvePath "/app/frontend" "index.html")
path "/" >=> Files.browseFileHome "index.html"
path "/" >=> Files.file "/app/frontend/index.html"

none of them work. I confirmed, the file is at /app/frontend/index.html

1

There are 1 best solutions below

4
On BEST ANSWER

Files.file doesn't look in the home folder, but Files.browseFileHome does:

path "/" >=> Files.browseFileHome "index.html"

I agree that the documentation is very fuzzy on this.