Add rewrite url middleware and error handing middleware