Welcome Guest, Not a member yet? Register   Sign In
redirect question
#1

Hi,

Can someone tell me why this is redirecting to localhost rather than the domain it is being executed on Huh

Code:
return redirect()->to('/admin/login');
Reply
#2

its not work in  construct 
it should  use filter 
PHP Code:
<?php namespace Myth\Auth\Filters;

use 
CodeIgniter\HTTP\RequestInterface;
use 
CodeIgniter\HTTP\ResponseInterface;
use 
CodeIgniter\Filters\FilterInterface;
use 
Config\App;

class 
LoginFilter implements FilterInterface
{
 
/**
 * Verifies that a user is logged in, or redirects to login.
 *
 * @param RequestInterface $request
 * @param array|null $params
 *
 * @return mixed
 */
 
public function before(RequestInterface $request$params null)
 {

 
$authenticate service('authentication');
 if (! 
$authenticate->check())
 {
 
session()->set('redirect_url'current_url());
 return 
redirect('login');
 }
 }

 
/**
 * @param RequestInterface  $request
 * @param ResponseInterface $response
 * @param array|null $arguments
 *
 * @return void
 */
 
public function after(RequestInterface $requestResponseInterface $response$arguments null)
 {
 }

but if you use in method
function  index(){
return  redirect()->to('login')
}
Enlightenment  Is  Freedom
Reply
#3

(10-11-2021, 03:13 AM)paulkd Wrote: Hi,

Can someone tell me why this is redirecting to localhost rather than the domain it is being executed on Huh

Code:
return redirect()->to('/admin/login');

You sure you don’t have “localhost” in app.baseURL in your .env file?
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#4

(This post was last modified: 10-12-2021, 11:01 PM by paulkd.)

(10-12-2021, 04:00 PM)includebeer Wrote:
(10-11-2021, 03:13 AM)paulkd Wrote: Hi,

Can someone tell me why this is redirecting to localhost rather than the domain it is being executed on Huh

Code:
return redirect()->to('/admin/login');

You sure you don’t have “localhost” in app.baseURL in your .env file?

Bingo!  Big Grin

The setting was actually commented out. Uncommenting and changing to the correct domain resolved the issue.

Thanks!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB