back function

DoxResponse back(
  1. DoxRequest req, {
  2. String fallback = '/',
})

A 302 redirect to the page the request came from (the Referer header), or to fallback when there is none.

Only a referer on the same host is used. A referer of another site goes to fallback, so back can not send users to other sites (open redirect).

req.session.flash('message', 'Saved');
return back(req);

Implementation

DoxResponse back(DoxRequest req, {String fallback = '/'}) {
  return redirect(
    sameHostUrl(req.referer(), req.header(HttpHeaders.hostHeader)) ?? fallback,
  );
}