Masonite - Corrupted Content error on redirection to '/'

129 Views Asked by At

I'm using the Masonite framework and whenever I have this code:

def another(self, Request):
    return Request.redirect('/')

Whenever that is hit and it is redirecting, it will either throw a Corrupted Content error or an Infinite Redirection error depending on the browser.

1

There are 1 best solutions below

0
On

Fix

This was fixed in Masonite 1.6.5 so you can just run:

pip install --upgrade masonite

and that should fix the problem.

The Problem

The problem was because of how Masonite compiled routes into a url. Some url's can be left untouched (such as redirecting to / or /home) but some need to be compiled down such as redirecting to /dashboard/user/@user/@id so Masonite has a special method for compiling routes.

Anyways, Masonite would also always prepend a / and there was a bug that would compile the route of / into // which typically makes the browser throw that error. That has since been tested and fixed.