After a POST action, reloading the browser results in a GET action.

46 views
Skip to first unread message

saraki

unread,
May 30, 2021, 9:17:54 PM5/30/21
to unpoly
After a POST action, reloading the browser results in a GET action.

You don't need to use the unpoly.js function, it can be generated by just loading the js.

I think this is the same problem as below.

Is there a workaround?

adam.me...@gmail.com

unread,
May 31, 2021, 10:57:19 AM5/31/21
to unpoly
Presuming this is on a Rails app?

When you reload, do you expect a POST?

Does your `form` use Unpoly to submit?

saraki

unread,
May 31, 2021, 8:56:23 PM5/31/21
to unpoly

>Presuming this is on a Rails app?
No, it's a java springboot application

>When you reload, do you expect a POST?
I want a warning to resubmit the form.

>Does your `form` use Unpoly to submit?
Even if you don't use unpoly to submit, just loading the <script> will trigger it.

A simple sample.
The behavior changes depending on whether the script tag is present or not.
(It's the same for version 1.0.0)

<html>
<head>
</head>
<body>
<form action=""  method="POST">
Reload(F5) after submit.<br>
<input type="text" name="test" value="test">
<button type="submit" >submit</button>
</form>
</body>
</html>


2021年5月31日月曜日 23:57:19 UTC+9 adam.me...@gmail.com:

adam.me...@gmail.com

unread,
Jun 1, 2021, 8:01:38 AM6/1/21
to unpoly
Thank you for clarifying. I think you're right, and it's indeed the same issue as the Turbolinks issue you referenced.
 
It looks like there's an un-merged patch for Turbolinks. I wonder if we could borrow some of the concepts from it. https://github.com/turbolinks/turbolinks/pull/495

Are you interested in taking a shot at it?

randl...@googlemail.com

unread,
Jun 1, 2021, 8:52:10 AM6/1/21
to unpoly
Hi everyone,

thanks for investigating.

I now made a change so Unpoly no longer replaces the initial state if the page was loaded from a POST request. This will be part of the next release candidate (2.0.0-rc10).

To allow Unpoly to read the initial request method, your server needs to send an _up_method cookie.

I'm having trouble understanding the Turbolinks fix for this. It looks like this would fix the case were the user reloads the initial, POST-requested page. But if the user loads the initial page with POST, advances a history entry and then goes back, Turbolinks would make a GET request to the initial POST URL. I'm assuming that Unpoly's solution is more correct here, although it does require the _up_method cookie.

Best regards
Henning

saraki

unread,
Jun 1, 2021, 9:25:26 PM6/1/21
to unpoly

thanks for replay 
great. I'll wait for the next release.
2021年6月1日火曜日 21:52:10 UTC+9 randl...@googlemail.com:
Reply all
Reply to author
Forward
0 new messages