-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asset files are not loading after a fresh Laravel Sail installation on MacOS #68
Comments
curl -s "https://laravel.build/example-app" | bash
cd example-app
./vendor/bin/sail up
sail composer require laravel/breeze
sail artisan breeze:install
sail npm install && sail npm run dev I've just followed these steps verbatim and the site is running as expected on my MacOS machine... Can you confirm the following:
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel([
'resources/css/app.css',
'resources/js/app.js',
]),
],
});
ports:
- '${APP_PORT:-80}:80'
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
|
I can confirm all of the above. Also, it appears the issue is limited to Safari. I tested the same address on Firefox and Chrome and the assets load fine. I haven't tested on Edge but I'm guessing it will work as well. |
I'm unable to replicate this in Safari. Everything is working as expected in Safari on my end. Toggling "Prevent cross-site tracking" on / off also has no impact for me. Are you accessing localhost over HTTP or HTTPS? |
I'm accessing localhost over HTTP. I don't know if it's relevant but I'm using an M1 Mac mini. Although, blaming it on apple silicon it's quite a leap. |
The only way I could get things to work on Valet/Safari/SSL is with the following. It would be nice not to have to explicitly set a domain path however as when you run vite.config.js
|
Hi @timacdonald, I'm getting very similar issues to the other users, and I'm running on an Intel Mac, with Docker Desktop 4.10+ As I prefer to use MariaDB over MySQL, I used the steps:
The
Docker compose file
Tested using Chrome, Safari, Edge and Firefox.
On everything except Safari, I've managed to view the content as it should be for the default layout. I use multiple browsers for testing to make sure that things are as I expect, so the fact that Safari is failing for some reason is a mild concern. More of a concern is also that the I have had no problems in the past with Mix. |
Facing a similar issue, blank page on port 3000. I'm not using docker.
UPDATE with Solution: |
@AdyGCode @Fedeorlandau Accessing the Vite dev server directly (http://localhost:3000 or http://localhost:5173, depending on whether you're running it inside Sail) is expected to return a blank screen at the moment as that's just where Vite serves assets for HMR. This has been improved with #57 as we'll now be outputting a default help screen to instruct users to run a dev server for Laravel. |
@AdyGCode @tuto1902 are either of you using any ad blocking plugins or anything in Safari? Could you confirm that the problem only exists in HMR mode? i.e. kill the dev server and run If you have valet installed could you try runnning And finally, can you confirm if the issue persists when you have Safari in a "vanilla" state with no extra plugins or configuration? Please also try resetting the experimental features... and then, if you have space, could you also try playing with these settings in Safari to see if you can make anything happen / get any further meaningful information from the console / requests. |
I have little snitch running, but turned off filtering as a test, no effect. HMR mode runs with assets compiled, the pages render as expected. |
That's good to hear - someone who comes straight from mix to vite would not be familiar with that little idiosyncrasy. |
Tim, I modified the URIs for "vite" on the rendered page to localhost from 0.0.0.0 on Safari, and the page rendered. |
After trying out your suggestions:
|
@timacdonald A small development. Just like @AdyGCode, if I manually change the href value of the link in the head from 0.0.0.0 to localhost (Ctr+Cmd+C > right click > edit attribure). The page suddenly loads fine. |
@tuto1902, @jessarcher, @timacdonald OK - I have found a workaround thanks to #42 plus the Spatie/Freek blade refresh settings. Edited the
Also, added the Freek/Spatie 'fix' for auto-reload on blade file updates, in the plugins array, after the
Full Code for the
Results are the page rendering as expected in Safari (logo colour changed in this test): |
@AdyGCode I tried your workaround but still doesn't work for me. I even tried setting |
This is a small video to demonstrate what I mean Screen.Recording.2022-07-10.at.9.19.38.PM.mov |
@tuto1902
You may also want to run The I also did force my cache to be cleared in Safari [ |
@AdyGCode Thanks for the reply. I tried all the suggestions: Btw, your reply made me think of this immortal line 🤣 |
Ok, so I think this is just a problem with my Mac mini, or the Mac OS version, or the version of Safari, or maybe an ancient curse passed down by generations... In any case, I just ran my own steps to reproduce in an old MacBook Air with Mac OS Big Sur and sure enough, everything worked fine out of the box. @timacdonald if there's no objection from anyone else, I think we can close this issue. 🤷🏻♂️ |
That happens, and given my configuration is a bit wild, I was wondering the same. If you get the chance to re-build the Mini then you may find it clears up the issue.
@timacdonald and @tuto1902 - No problems closing, but it may be worth adding a note that in some situations, the HMR option under server may be required. |
Thanks all |
Description:
After a fresh installation of Laravel Sail and Laravel Breeze, css and js files are not loading in the browser
Steps To Reproduce:
vite v2.9.13 dev server running at:
When I visit localhost/login, the console shows "Failed to load resource: bad URL" and these are the locations where the browser is looking for the resources:
http://0.0.0.0:5173/resources/css/app.css
http://0.0.0.0:5173/@vite/client
http://0.0.0.0:5173/resources/js/app.js
This is how the login page looks like
The text was updated successfully, but these errors were encountered: