0

I'm using akka-http for my React-based single page application's web server, and having issues where when I refresh my website. I get back a 404 for the requested resource (just index.html). Doing a "super refresh" (ctrl + refresh) works fine and everything loads as expected. But when I do a normal refresh, and the if-modified-since header is included in the request header, I noticed that the server gives back a 404 response.

~ {
  getFromFile(s"$STATIC_CONTENT_ROOT/index.html")
}

To make sure this was actually the issue, I did a sanity check. I updated the code to update the modified date of all files in the resources folder (all the js files and the index.html) to be the current time whenever the catch-all / refresh endpoint was hit, and noticed that this fixed the refresh issue. However, the "solution" only works locally since I don't have write permissions on these resources once they're deployed to the actual dev or production shared hosts.

I'm now just looking for a solution that allows me to either ignore this part of the header or actually handle it properly. I've tried using the conditional(...) directive of akka-http but haven't had any luck.

Has anyone ever run into this issue before? And had success fixing this issue?

CustardBun
  • 3,457
  • 8
  • 39
  • 65
  • Also reported at https://github.com/akka/akka-http/issues/1838 . Sounds like it could be a bug, a small project or test that reproduces the situation would be great! – Arnout Engelen Feb 13 '18 at 12:36

1 Answers1

1

I found out that the getFromFile directive actually uses the conditional directive internally. This can be shut off by configuring the RoutingSettings.

Jeffrey Chung
  • 19,319
  • 8
  • 34
  • 54
CustardBun
  • 3,457
  • 8
  • 39
  • 65