I've been developing a web app in Laravel. I've recently wanted to deploy a preview in the production server so I uploaded the files to the hostinger but the scss did not load nor the routing to my controllers. I didn't really find much info on the topic since I don't really know what to look for, I believe it may be my htaccess file but idk id that even makes sense:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /folder1/
RewriteRule ^(.*)$ public/index.php/$1 [L]
</IfModule>
I ran NPM run production and Im working with mix, my package.json is configured like this:
{
"private": true,
"type": "commonjs",
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"hot": "mix hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"axios": "^1.1.2",
"laravel-mix": "^6.0.49",
"laravel-vite-plugin": "^0.7.5",
"resolve-url-loader": "^5.0.0",
"sass": "^1.63.6",
"sass-loader": "^12.1.0",
"vite": "^4.0.0"
},
"dependencies": {
"bootstrap": "^5.3.0",
"jquery": "^3.7.0",
"toastr": "^2.1.4",
"webpack": "^5.88.1"
}
}
My webApp works perfectly on localhost, but then again on prod my scss styles dont load nor does it fin my controllers. Im calling the html tag for scss in a layout head tag like this:
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
It was fixed by editing my public/mix-manifest.json
changing the paths to a relative route:
from this
{
"/js/app.js": "/js/app.js",
"/css/app.css": "/css/app.css"}
to this:
{
"/js/app.js": "./js/app.js",
"/css/app.css": "./css/app.css"}
and my htaccess generated with looking like this:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>