1

I have a Rails 4.1 application with unicorn and nginx. But somehow/mysteriously my POST request turn into GET request. Here is the request header:

Remote Address: <<IP>>
Request URL: <<URL>>
Request Method:POST
Status Code:301 Moved Permanently
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,ru;q=0.6,bg;q=0.4,mn;q=0.2,nb;q=0.2
Cache-Control:no-cache
Connection:keep-alive
Content-Length:14269
Content-Type:application/x-www-form-urlencoded
Cookie:<<COOKIES>>
Host:<<HOST>>
Origin:<<ORIGIN>>
Pragma:no-cache
Referer:<<REFERER>>
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
Form Dataview sourceview URL encoded
utf8:✓
authenticity_token:<<TOKEN>>
<< FORM DATA >>
Response Headersview source
Connection:keep-alive
Content-Length:184
Content-Type:text/html
Date:Wed, 04 Jun 2014 02:44:35 GMT
Location:<< REDIRECT LOCATION >>
Server:nginx/1.6.0

For security reason I hide some infos. In my development env everything working fine. Any idea? If you need more info let me know.

UPDATED: I created a new question. POST request turns into GET request

Community
  • 1
  • 1
Zeck
  • 6,433
  • 21
  • 71
  • 111

1 Answers1

2

It's because Status Code:301 Moved Permanently Just avoid that rewrite updating your form action URL or ajax request URL. (It's browser default behavior to re-request 301 anwswers with GET,I'll add a link to source info when I find it)

EDIT:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

Not default, but erroneous. Maybe "common" if ajax request, I think

miguel-svq
  • 2,136
  • 9
  • 11
  • Hmm. Okay thank you for reply. I'm using PJAX maybe it's related to it. – Zeck Jun 04 '14 at 03:16
  • So what should I do? In this page I'm using Ajax for file upload and PJAX for loading page itself. – Zeck Jun 04 '14 at 03:19
  • ruby-on-rails nginx unicorn... and now PJAX. You have a lot of places to look for in, but i'd start with nginx configuration and checking the request URL rewrite/redirect chain. – miguel-svq Jun 04 '14 at 03:20
  • I'm unsure about how to do it (quite "newbie" here) Opening a new question? I know if we keep "replying" comments the site offer an automatic "move this to a chat (Forum?)" It's up to you what request/site information can show. – miguel-svq Jun 04 '14 at 03:28
  • Thank you helping me :) I'm going to create a new question. I will link it to here. – Zeck Jun 04 '14 at 03:34
  • See you there (but not now, time up for today) – miguel-svq Jun 04 '14 at 03:39
  • Okay Have a nice day! :) – Zeck Jun 04 '14 at 03:40