Skip to content

redirect function don't redirect to base_url #1611

Description

@dasua

Describe the bug
This redirects fails in my controller when upgrading from V4.0.0-alpha2 to V4.0.0-alpha3 (or develop branch):

return redirect(base_url('/login'))->with('tplError', 'Invalid username or password');
return redirect('/login')->with('tplError', 'Invalid username or password');
return redirect(base_url('/dashboard/1'))->with('notifSuccess', 'Login OK');

The value of base_url('/login') is https://dev.dasua.es/login and this works when I write in the browser (is a valid url).

The value of base_url('/dashboard/1') is https://dev.dasua.es/dashboard/1 and this works when I write in the browser (is a valid url).

Throws CodeIgniter\HTTP\Exceptions\HTTPException BASEPATH/HTTP/Exceptions/HTTPException.php at line 106

At CodeIgniter\Router\RouteCollection::reverseRoute method, I get this values:
A partital content of $this->routes is:

reset($vars) array (10)
    * => array (0)
    options => array (0)
    get => array (6)
        / => array (1)
        login => array (1)
            route => array (1)
                login => string (32) "\App\Controllers\Auth::loginForm"
        logout => array (1)
        dashboard/([0-9]+) => array (1)
            route => array (1)
                dashboard/([0-9]+) => string (36) "\App\Controllers\Dashboard::index/$1"

The value of $search method parameter is https://dev.dasua.es/login.

The value of ...$params is an empty array.

CodeIgniter 4 version
v4.0.0-alpha.3 or develop branch

Affected module(s)
CodeIgniter\Router\RouteCollection::reverseRoute()

Expected behavior, and steps to reproduce if appropriate
I think (as describe the function doc):
return redirect(base_url('/login'))->with('tplError', 'Invalid username or password');
return redirect('/login')->with('tplError', 'Invalid username or password');

Must have the same behavior as:
return redirect('login')->with('tplError', 'Invalid username or password'); (this works)

And:
return redirect(base_url('/dashboard/1'))->with('notifSuccess', 'Login OK');
return redirect('/dashboard/1')->with('notifSuccess', 'Login OK');
return redirect('dashboard/1')->with('notifSuccess', 'Login OK');

Must have the same behavior as:

$this->session->setFlashdata('notifSuccess', 'Login OK');
return $this->response->redirect(base_url('/dashboard/1'));

Context

  • OS: Debian Stretch
  • Web server Apache 2.4
  • PHP version 7.2

debug
exception

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions