bekanur98
bekanur98

Reputation: 520

Symfony easyadmin ERR_TOO_MANY_REDIRECTS on production server

I implemented the admin panel using a EasyAdminBundle 3.0 version.

I have the following controller with routing annotation:

/**
 * @Route("/admin/dashboard", name="admin")
 */
public function index():Response
{
    $routeBuilder = $this->get(AdminUrlGenerator::class);

    return $this->redirect($routeBuilder->setController(UserCrudController:>
}

Another route is working fine, only easyadmin routes are not working. This works fine on my development server. However, on my production server, I get an infinite redirect route. I looked through the logs and it is caused by Symfony, not Apache. It does this over and over until my browser stops

enter image description here

Upvotes: 1

Views: 816

Answers (3)

Max
Max

Reputation: 1

I had the same issue for dev and prod. My problem was in nginx.

location / {
    try_files $uri $uri/ /public/index.php;
}

It was solved by changing nginx configs.

location / {
    try_files $uri $uri/ /public/index.php?$query_string;
}

Upvotes: 0

user16087481
user16087481

Reputation: 1

I made a mistake in the last post. It was like this in my controller. Not the name but the path. My bad, sorry.

/**
 * @IsGranted("ROLE_ADMIN")
 * @Route("/admin/", name="admin")
 */
public function index():Response
{
    $routeBuilder = $this->get(AdminUrlGenerator::class);

    return $this->redirect($routeBuilder->setController(UserCrudController:>
}

Upvotes: 0

user16075698
user16075698

Reputation: 11

I had the same issue when i put in prod and finally it was solved by adding a slash to the route name

 /**
 * @Route("/admin/dashboard", name="admin/")
 */
public function index():Response
{
    $routeBuilder = $this->get(AdminUrlGenerator::class);

    return $this->redirect($routeBuilder->setController(UserCrudController:>
}

Upvotes: 1

Related Questions