# ERR_TO_MANY_REDIRECTS on new Radicle install with Laravel Valet

**URL:** https://discourse.roots.io/t/err-to-many-redirects-on-new-radicle-install-with-laravel-valet/25037
**Category:** radicle
**Tags:** valet
**Created:** 2023-03-28T14:33:07Z
**Posts:** 14

## Post 1 by @linksmith — 2023-03-28T14:33:07Z

I just installed a new Radicle project with composer, and setup my local environment. I’m running the site via Valet. Other Bedrock sites configured in the same way work fine, although they of course use `/web` as webroot and not `/public`.

What am I doing wrong?

`bug.config.js`:

```
bud
    .proxy(`http://somesite.nl.test`)
    .serve(`http://localhost:4000`)
```

`.env`:

```
WP_ENV='development'
WP_HOME='http://somesite.nl.test'
WP_SITEURL="${WP_HOME}/wp"
```

---

## Post 2 by @ben — 2023-03-28T14:55:50Z

Are you using Valet v4?

---

## Post 3 by @linksmith — 2023-03-28T15:06:40Z

v3.3.2 do you think an upgrade will help?

---

## Post 4 by @ben — 2023-03-28T15:09:52Z

Worth a shot! Another user had issues with Radicle and Valet v3, but reported that after upgrading to Valet v4 that they were resolved

---

## Post 5 by @linksmith — 2023-03-28T15:25:31Z

I’ve upgraded to Valet v4.0.1

Now I get a `404 - Not Found` error generated by Valet. Other sites running Bedrock are still working fine.

Thanks for the help by the way. Any more thoughts?

---

## Post 6 by @csorrentino — 2023-03-28T19:41:12Z

You may need a **[custom valet driver](https://laravel.com/docs/10.x/valet#custom-valet-drivers)** for Radicle.

I made one that I intend to try but have been testing Radicle with lando instead of valet, so this is still **untested**. I used the SampleValetDriver that ships with Valet and a modified version **[danielroe/trellis-valet-driver](https://github.com/danielroe/trellis-valet-driver)** to make a custom driver. Maybe this will work for you or at least give you some ideas as you troubleshoot:

```
// ~/.config/valet/Drivers/RadicleValetDriver.php

<?php
namespace Valet\Drivers\Custom;

use Valet\Drivers\ValetDriver;

class RadicleValetDriver extends ValetDriver
{
    /**
     * Determine if the driver serves the request.
     *
     * @param string $sitePath
     * @param string $siteName
     * @param string $uri
     * @return bool
     */
    public function serves(string $sitePath, string $siteName, string $uri): bool
    {
        return file_exists($sitePath . '/public/content/mu-plugins/bedrock-autoloader.php') &&
               file_exists($sitePath . '/public/wp-config.php') &&
               file_exists($sitePath . '/bedrock/application.php');
    }

    /**
     * Determine if the incoming request is for a static file.
     *
     * @param string $sitePath
     * @param string $siteName
     * @param string $uri
     * @return string|false
     */
    public function isStaticFile(string $sitePath, string $siteName, string $uri)/*: string|false */
    {
        $staticFilePath = $sitePath . '/public' . $uri;
        if ($this->isActualFile($staticFilePath)) {
            return $staticFilePath;
        }
        return false;
    }

    /**
     * Get the fully resolved path to the application's front controller.
     *
     * @param string $sitePath
     * @param string $siteName
     * @param string $uri
     * @return string
     */
    public function frontControllerPath(string $sitePath, string $siteName, string $uri): string
    {
        $_SERVER['PHP_SELF'] = $uri;
        if (strpos($uri, '/wp/') === 0) {
            return is_dir($sitePath . '/public' . $uri)
                            ? $sitePath . '/public' . $this->forceTrailingSlash($uri) . '/index.php'
                            : $sitePath . '/public' . $uri;
        }
        return $sitePath . '/public/index.php';
    }

    /**
     * Redirect to uri with trailing slash.
     *
     * @param string $uri
     * @return string
     */
    private function forceTrailingSlash(string $uri)
    {
        if (substr($uri, -1 * strlen('/wp/wp-admin')) == '/wp/wp-admin') {
            header('Location: ' . $uri . '/');
            die;
        }
        return $uri;
    }
}
```

---

## Post 7 by @linksmith — 2023-03-28T21:44:28Z

@csorrentino I just came to the exact same conclusion, and almost the exact some code, and was ready to post the solution here. No nee, because you already posted the the solution. You were to fast! Thanks for the help.

---

## Post 8 by @Davide_Prevosto — 2023-05-01T16:40:21Z

I used your driver @csorrentino and I was able to install Radicle using Valet as development environment.

Thank you

---

## Post 9 by @ben — 2023-05-02T15:25:36Z

Circling back on here from [https://github.com/roots/radicle/issues/33](https://github.com/roots/radicle/issues/33) — @csorrentino would you be interested in submitting a PR to [https://github.com/laravel/valet](https://github.com/laravel/valet) with your driver?

---

## Post 10 by @theutz — 2023-05-02T15:33:31Z

The Laravel team was really receptive to the PR, so it could be an easy win for you! :smiley:

---

## Post 11 by @csorrentino — 2023-05-02T18:22:32Z

Yeah, I’m happy to submit a PR for that. I’ll update this thread as soon as I do.

---

## Post 12 by @csorrentino — 2023-05-03T16:02:06Z

Ok, I’ve submitted a [pull request](https://github.com/laravel/valet/pull/1413) to add this driver. :crossed_fingers:

---

## Post 13 by @csorrentino — 2023-05-15T16:41:37Z

Update: the latest valet release (v4.1.0) now includes the Radicle driver. [Release v4.1.0 · laravel/valet · GitHub](https://github.com/laravel/valet/releases/tag/v4.1.0)

---

## Post 14 by @ben — 2023-05-15T17:14:06Z

Thanks so much for both the driver and getting it added to Valet! :pray:
