SAFE-Stack / docs

https://safe-stack.github.io/docs/
MIT License
145 stars 69 forks source link

Bug in Saturn to Giraffe guide #362

Closed jwthomson closed 2 months ago

jwthomson commented 2 months ago

Someone on the F# discord mentioned that the guide for switching from Saturn to Giraffe did not work for them.

Repro steps:

  1. Create SAFE app
  2. Follow the guide (https://safe-stack.github.io/docs/recipes/client-server/saturn-to-giraffe/)
  3. Run the bundled version of the app:
      dotnet run Bundle
      cd deploy
      Server.exe

Expectation: Hit localhost:5000 in your browser and see the default todo app.

Actual result: Hit localhost:5000 in your browser and get a 404 error.

The fact that the application does work in dev mode dotnet run but fails once bundled - indicates to me that there is an an inconsistency with the way Vite handles incoming requests vs how Kestrel/IIS handles incoming requests.

I think the difference in behaviour is due to Kestrel is not remapping root requests to index.html by default. In contrast, Vite defaults to serving index.html for root requests. (and this seems to be non-negotiable! https://vitejs.dev/guide/#index-html-and-project-root)

For me, the workaround posted in Discord - renaming the public folder to wwwroot - did not work.

Working on a PR to fix.

astrobytez commented 2 months ago

That was me on Discord. Thanks for putting this together! :)

Larocceau commented 2 months ago

@jwthomson can this be closed?

jwthomson commented 2 months ago

@Larocceau yes 😄