I am deploying Laravel 9 project to shared hosting (without the ability to ssh into the server so I can’t npm run build in the server) and I am getting this error:
Vite manifest not found at: laravel_project/public/build/manifest.json
I am using FileZilla to upload the project to the CPanel, I uploaded the public folder into public_html and configured the index.php file.
Before uploading the project i run npm run build locally on my localhost and everything works ok there.
Does anyone have a solution for this ?
I tried changing the APP_ENV=production but it didn’t work.
2
Answers
so I found a solution for that which is:
put all my local laravel files and folders including the public folder (of course after running composer install and npm run build locally) inside the public_html directory in the server
now inside the server in public_html directory move the two files .htaccess and index.php of the public folder one level up in way so that the index.php file and the .htaccess file are directly inside the public_html directory (this way you don't have to include /public in your url but instead access the application directly when you visit your website)
configure the content of index.php you just moved from public up to public_html in a way that its links point correctly to the content of the app inside public_html
for example:
__DIR__.'/../storage/framework/maintenance.php'
becomes
__DIR__.'/storage/framework/maintenance.php'
so that the /.. is removed
and the other links too like:
__DIR__.'/../vendor/autoload.php'
becomes
__DIR__.'/vendor/autoload.php'
and
__DIR__.'/../bootstrap/app.php'
becomes
__DIR__.'/bootstrap/app.php'
I am having the exact same issue. What helped me is I not only added public contents to public_html but also additionally added the public folder to the production server with the same content. So it’s duplicated files in public_html and public, but I think it’s a better solution than adding the whole project into the public_html folder.
I would like to find a nicer solution for this issue though.