lolsokje's avatar

Laravel Valet; rewriting URLs for a specific site

I use Valet for all of my personal projects, simply because it just works and is often less of a hassle to set up than Docker. I've recently however changed jobs, where one of my new colleagues had set up a Docker environment for himself, and suggested I set that up as well. While it works fine, I'd much prefer sticking with Valet so I don't have to start/stop either of them any time I want to work on a project.

While I can get the project running with Valet without much issue (despite it being a Symfony project), I've got an issue with the assets.

Because the live application runs on a subdirectory of the main website (so https://website.com/[subdirectory] instead of https://website.com), the asset public path within Webpack has been set to /[subdirectory]/build (.setPublicPath('/[subdirectory]/build')).

In my colleague's Docker Nginx configuration he's accounted for this by adding

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

which in my presumption means, any request to [subdirectory]/build will instead go to /build, which on our local environment would be correct.

I've tried adding something similar to the site's specific Nginx config file under ~/.config/valet/Nginx, but I still get a 404 on any of the requested assets.

Is there a way to solve this issue? Not being able to load these assets is the only thing preventing me from moving to Valet.

0 likes
0 replies

Please or to participate in this conversation.