I created an assetHandler to server static angular files but when I first request the handler it does not include any CSRF token as a cookie thus if I submit a form it does not include the CSRF token and I get the Unauthenticated User error.
Is it possible to explicitly set the CSRF token?
Here is the handler I created.
def assetHandler(file: String): Action[AnyContent] = {
var name = file
if (!file.contains(".")) {
name = Seq("index.html").mkString
}
controllers.Assets.at("/public/lib/platform", name)
}
PS. If I first request another regular controller (e.g. /api/ping) Play sends the CSRF for that request and thus angular is able to use it in every request. Is it a good practise to call an extra controller?