joshuapphillips's avatar

My CSS is not linking properly on production server.

I am using Jetstream 2 and vite. Everything works fine locally but after placing my app on a server all the styles have stopped working.

Blade layout has this in the template

@vite(['resources/css/app.css', 'resources/js/app.js'])

Which outputs this

<script type="module" src="http://127.0.0.1:3000/@vite/client"></script>
<link rel="stylesheet" href="http://127.0.0.1:3000/resources/css/app.css" />
<script type="module" src="http://127.0.0.1:3000/resources/js/app.js"></script>

But these paths are wrong.

How do I correct them?

0 likes
11 replies
RavindraReddy's avatar

@Niush Thank You for Addressing this, I am writing this to make clear an issue, First I built a production ready build, then uploaded it to server;

npm run build

In some CPANEL (if you are using a Shared Hosting) you get an option to set document root, which solves the most of the issue, But in some like Hostinger Hpanel, you dont have an option.

So, Watching some youtube Videos, Simply Need to create two files .HTACCESS, INDEX.php File in root directory; this solves the issue, however you styles may not work as there are not linked correctly;

After wasting a day, came here found this solution by @niush Thanks buddy; Just Add this line in you .env;

ASSET_URL=https://domain.tld/public

This will surely work.

Sinnbeck's avatar

Did you compile locally or on production?

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@joshuapphillips and you are using npm run build? And check if you have a file named hot in the public directory. If you do, delete it

5 likes
Sinnbeck's avatar

@joshuapphillips it is created when running npm run dev and removed when you stop it. So perhaps it wasn't stopped correctly and was committed to git by accident?

1 like
shadkamel's avatar

hello @Sinnbeck , i have same problem, i deleted the hot file but the css is still not working but i am using tailwindcss can u help me please ?

Sinnbeck's avatar

@shadkamel Please make a new thread :) This one is already solved and your problem might be different.

1 like
shadkamel's avatar

@Sinnbeck thank you, while waiting for your answer, i was searching for a solution, and i found this issue report and the solution is included. <3

Please or to participate in this conversation.