Reputation: 3020
Im running play 2.4.6
I have the following in my routes file:
POST /register controllers.Auth.saveRegistration()
The Problem:
I have a form that makes a POST to /register with a payload, this works fine locally & on staging. However in production generates a subsequent GET request.
I log all routes and action methods out to my logger by override Global::onRouteRequest && Global::onRequest
Production Logs:
[info] application - [AUTH] Create::personalInfo() accessed for session
[info] application - [ROUTE] /register POST
[info] application - [ROUTE] actionMethod.name = saveRegistration()
[info] application - [ROUTE] /register GET
Staging Logs:
[info] application - [AUTH] Create::personalInfo() accessed for session
[info] application - [ROUTE] /register POST
[info] application - [ROUTE] actionMethod.name = saveRegistration()
[info] application - [AUTH] Call Auth::saveRegistration
[info] application - [AUTH] Person::createOrUpdate creating new user
[info] application - [AUTH] Calling Auth::saveRegistration::AuthActions::loginPerson()
[info] application - [AUTH] Auth::saveRegistration::redirect to /myfavoriteroute
Additional Context
If the saveRegistrationMethod()
is called, when its executed then then the first thing it should write should be Call Auth::saveRegistration
This means saveRegistrationMethod()
is never called in production, and its generates a GET request instead.
Also: The browser shows a Response Code of 303 - response attached here
HTTP/1.1 303 See Other
Server: Cowboy
Connection: keep-alive
Vary: Accept-Encoding
Location: https://www.----.com/register
Content-Length: 20
Content-Encoding: gzip
Content-Language: en-US
Access-Control-Allow-Origin: *
Date: Mon, 01 Aug 2016 18:18:51 GMT
Via: 1.1 vegur
Also: Built using SBT_CLEAN=True on Heroku - verified in build logs..
Question:
What would cause a POST to generate a GET, and what might cause these environmental discrepencies?
Upvotes: 0
Views: 111
Reputation: 12850
It looks like what's happening is your application is receiving the POST request, and then sending a 303 redirect back to the browser, possibly to itself, or maybe to some other resource, which might then be redirecting back, and in accordance with the HTTP spec, the browser is making a GET request because browsers are not allowed to make a POST request after receiving a 303 redirect, they must switch to GET.
Anyway, what you need to do is have a look in your browser network console to see what the chain of requests are. If the the browser is receiving a 303 response back to the first POST, what is the Location header that it's being redirected to? By the way, there is nothing in Play that will automatically generate a 303 redirect, perhaps you have some filter that is redirecting that you're not aware of.
Upvotes: 1