Ruby-on-Rails: How to get rid of “you are being redirected” page

前端 未结 4 640
孤街浪徒
孤街浪徒 2021-01-01 13:00

I am overriding Devise\'s failure response so that I can set a 401 status code. However, when the user fails to sign in, they are redirected to a page with a \"you are being

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-01 13:17

    Proper HTTP statuses for a redirection are in the 30x form (301 and 302 being the most frequently used). By default, the redirect_to helper sets a 302 status header on the HTTP response. If you override that and set that to a 401, your web browser will assume that the response is a regular web page and will render the response body --which, in a redirection, is the boilerplate text "You are being redirected".

提交回复
热议问题