0

I deployed my laravel 11 app in a subfolder on my hosting and it works (only public folder is in subfolder, the app itself is in root not publicly accessible off course).

The prod asset build I had to do it locally because of the lack of npm on my webhosting, so locally I work in root, the hosting is on subfolder.

On my hosting I can log in and navigate within the one Page App driven by Inertia and Vue. But page refreshes give a 404.

Because vue rewrites the links to the domain root so In fact by entering vue I leave

mydomain.com/subfolder/page

and navigate in

mydomain.com/page

And as long as I move within the one-page app everything works, as the routing is done within vue itself and the browser url is just rewritten but not reloaded. The problem is when I (or a potential user) tries a page refresh in the browser which obviously produces a 404 Not found error as the vue urls do not into account the subfolder installation.

THE QUESTION IS:

I have seen many proposals to solve this with .env and/or .htaccess or grouping the routes in web.php, etc., but all refer somehow to the Laravel Routing itself, not the Vue Inertia route re-writing, much less in one page apps.

I am also very conscious that I or a deployer could simply rewrite all Vue routes to use this subfolder, BUT: I wonder if there's a default param for Inertia/Vue which accounts for that case (installation in subfolder)? A simple param or something which doesn't force too much changes and changes the routes to include the subfolder? Which is the easiest way to tell Inertia/vue it was installed in a subfolder? Because apparently just changing the APP_URL in the .env file is not enough.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.