{"action":"opened","issue":{"url":"https://api.github.com/repos/dotnet-websharper/suave/issues/12","repository_url":"https://api.github.com/repos/dotnet-websharper/suave","labels_url":"https://api.github.com/repos/dotnet-websharper/suave/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/dotnet-websharper/suave/issues/12/comments","events_url":"https://api.github.com/repos/dotnet-websharper/suave/issues/12/events","html_url":"https://github.com/dotnet-websharper/suave/issues/12","id":310321255,"number":12,"title":"WebSharper Suave-hosted site -- missing support for static files?","user":{"login":"nightroman","id":927533,"avatar_url":"https://avatars3.githubusercontent.com/u/927533?v=4","gravatar_id":"","url":"https://api.github.com/users/nightroman","html_url":"https://github.com/nightroman","followers_url":"https://api.github.com/users/nightroman/followers","following_url":"https://api.github.com/users/nightroman/following{/other_user}","gists_url":"https://api.github.com/users/nightroman/gists{/gist_id}","starred_url":"https://api.github.com/users/nightroman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nightroman/subscriptions","organizations_url":"https://api.github.com/users/nightroman/orgs","repos_url":"https://api.github.com/users/nightroman/repos","events_url":"https://api.github.com/users/nightroman/events{/privacy}","received_events_url":"https://api.github.com/users/nightroman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-01T12:49:36Z","updated_at":"2018-04-01T12:49:36Z","closed_at":null,"author_association":"NONE","body":"I am playing with WebSharper 4 but the issue is not necessarily new.\r\n\r\nPerhaps I miss something. In a WebSharper 4 Suave-hosted site project created\r\nfrom the template, I cannot find a way to link static files (css) in my main\r\nhtml page. The Chrome debugger shows errors on loading such files.\r\n\r\nCompare: if I create the similar Owin-hosted site project from the template\r\nthen I can link static files (css) right away and all works as expected.\r\n\r\nI noticed that Owin-host code has some explicit mention of static files:\r\n\r\n```fsharp\r\nuse server = WebApp.Start(url, fun appB ->\r\n    appB.UseStaticFiles(\r\n            StaticFileOptions(\r\n                FileSystem = PhysicalFileSystem(rootDirectory)))\r\n        .UseSitelet(rootDirectory, Site.Main)\r\n    |> ignore)\r\n```\r\n\r\nI cannot find any Suave-host options related to static files. If it is my bad,\r\nplease forgive me and point me to the right direction. I am an novice.\r\n\r\nI found a similar question for Suave itself. The answer suggests using\r\n`Files.browseHome`, see [stackoverflow](https://stackoverflow.com/a/35058060/323582).\r\n\r\nThen I made an naive hack in [WebSharper.Suave/Main.fs](https://github.com/dotnet-websharper/suave/blob/master/WebSharper.Suave/Main.fs):\r\n\r\n```fsharp\r\nmatch defaultArg ServeResources true with\r\n| true ->\r\n    choose [\r\n        subPath \"Scripts\"\r\n        subPath \"Content\"\r\n        Files.browseHome // <- this is the important part\r\n        siteletWebPart\r\n    ]\r\n```\r\n\r\nand my static files started to work. I am not suggesting this as a fix. But if\r\nthis makes sense I would expect a configuration option which tells\r\nto use this handler among the others.\r\n\r\n---\r\n\r\nHow to repro\r\n\r\n- Visual Studio 15.6.4\r\n- Visual Studio WebSharper extension 4.2.8.227\r\n- New project from Visual F# \\ WebSharper \\ WebSharper 4 Suave-hosted site\r\n- Edit `Main.html` and move its inline styles to the new file, say, `css/app.css`\r\n- Add the link `<link rel=\"stylesheet\" href=\"/css/app.css\"/>` to `Main.html`\r\n- Build\r\n- Run\r\n- Open the browser (Chrome) and navigate to \"http://127.0.0.1:8080\"\r\n\r\nAs a result, the main page is shown style-less and the Chrome console log shows\r\nerrors on loading `app.css`."}}
{"actor":{"display_login":"nightroman"}}