Rewriting asset URLs in Laravel Valet

120 Views Asked by At

I use Laravel Valet for all of my personal projects, since I find it easier to get working than Docker. However I recently started a new job where one of my colleagues set up a Docker environment for himself, and he shared it with me. It works, but it means I now have to start/stop Valet/Docker any time I want to work on a specific website, which is a bit of a headache.

I've tried setting up my new job's project (a Symfony project) on Valet, and this largely works fine. However for reasons still unbeknownst to me, the assets are built into a subdirectory (so [subdir]/build instead of /build). Because the directory doesn't exist, the asset files can't be found in my Valet setup.

My colleague's Docker container has accounted for this by adding

location /[subdirectory] {
    rewrite ^/[subdirectory](.*)$ /$1 last;
}

to his Nginx configuration which works, but when I do the same in my Valet setup, I still get 404s for all assets.

Is there a way I can rewrite asset URLs similarly with Valet?

0

There are 0 best solutions below