Reputation: 331
I'm having a trouble with Vite in Laravel. I ran the command npm run build and then I uploaded files to my shared hosting. But it doesn't load css and js files.
I've put @vite(['resources/css/admin.css', 'resources/js/app.js'])
at the top of the script.
Then I ran the command npm run build
.
And then uploaded all files to my shared hosting.
I tried to open the page. Style and JS files looks like this on page source;
<script type="module" src="http://127.0.0.1:5173/@vite/client"></script>
<link rel="stylesheet" href="http://127.0.0.1:5173/resources/css/admin.css" />
<script type="module" src="http://127.0.0.1:5173/resources/js/app.js"></script>
And it gives me these errors in browser console obviously because it tries to get files from localhost.
Which configurations should I make in Vite?
Upvotes: 4
Views: 10944
Reputation: 331
I found the solution. The problem was the hot file in public. It will be fixed when you delete public/hot
file. Do not forget to run npm run build command before you upload your files.
Upvotes: 28
Reputation: 1
that's a silly problem, you are sending the requests to the http://127.0.0.1 not the host! you have to send the request to for expample https://hostname.com not http://127.0.0.1
Upvotes: -2