Play! Framework on Heroku: validation.keep() isn&#

2019-08-03 03:05发布

问题:

I'm using Heroku to deploy my Play! framework app. I have a form that uses the standard structure of

public static void showForm() {
    render();
}

public static void handleForm(@Required param, @Required otherParam, etc) {
    if (validation.hasErrors()) {
        validation.keep();
        showForm();
    } else {
        //process form parameters
    }
}

This works fine on:

  • dev machine running HTTP at localhost:9000
  • heroku running HTTP at www.myapp.com
  • dev machine running HTTPS at localhost:9443

However, for forms that do this on Heroku over HTTPS at secure.myapp.com using hostname-based SSL, the validations don't show up. I think the problem is that validation.keep() isn't working.

If validation.keep() makes a cookie, and the problem has something to do with the difference between www.myapp.com and secure.myapp.com, then I might have a deeper problem because:

  • I already have application.defaultCookieDomain=.myapp.com, as per this question.
  • I think that both the GET and the POST are happening over HTTPS, so I think they have the same domain anyway...
    • The form's GET is definitely over HTTPS
    • When the form's data is processed, its result is definitely shown over HTTPS
    • I guess it's possible that the POST is happening over HTTP (and thus www.* instead of secure.*, but I'm not sure how to check).

Anybody have any guesses as to what's going wrong?

回答1:

There is currently an incompatibility in the ssl (x-forwarded-proto) support for play on heroku that causes all requests to be considered insecure.

https://play.lighthouseapp.com/projects/57987/tickets/1385-requests-are-never-secure-on-heroku-when-using-ssl

So maybe this is related to the cookies your browser is sending back?