2

I'm using the wai-app-static static package to serve a small website. Originally I called it as:

staticApp defaultFileServerSettings root 

and all was right with the world. I wanted to switch to using defaultWebAppSettings, though, (as this is a website). I was able to get that to work, such that if I went to http://localhost:3000/index.html, it was fine, but I also need to set up a redirect from the root folder to the index site (viz. http://localhost:3000 --> http://localhost:3000/index.html).

Based on what I saw in the code, I tried a couple of variations of:

(defaultWebAppSettings root) { ssIndices = map unsafeToPiece ["index.html"],
                               ssRedirectToIndex = True }

I'm able to compile and run the server, but I can't get the redirection to work.

Any pointers or ideas would be greatly appreciated!

Thanks

unor
  • 92,415
  • 26
  • 211
  • 360

2 Answers2

1

Hmm, I didn't know about the ssIndices or ssRedirectToIndex settings. What I did for my app that has dynamic and static parts, was on requests to /, alter that request to say /index.html instead and send it to the "static server". https://github.com/LeifW/online-typechecker/blob/master/index.hs#L20

pdxleif
  • 1,750
  • 16
  • 15
1

This code works for me

httpApp :: Wai.Application
httpApp = Static.staticApp $ s {Static.ssIndices = [Static.unsafeToPiece "index.html"]} where s = Static.defaultWebAppSettings "./static"
Maris Orbidans
  • 163
  • 2
  • 4