Skip to content
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

Unable to load Flux from route flux/flux.js/css #444

Open
labomatik opened this issue Dec 9, 2024 · 8 comments
Open

Unable to load Flux from route flux/flux.js/css #444

labomatik opened this issue Dec 9, 2024 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@labomatik
Copy link

What were you trying to do?

I'm trying to integrate flux inside a standard laravel app with NativePHP

What happened?

On my dev environnement all is perfect, files from flux can be loaded

After installation on windows machine here are the errors that are displayed using DevTools:

Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://127.0.0.1:8100/flux/flux.css?id=3324411c

In sentry we have more details:
filemtime(): stat failed for /Users/cris/project_nativephp/vendor/livewire/flux/src/../../flux-pro/dist/flux.css

How to reproduce the bug

Install Flux in the project
https://fluxui.dev/docs/installation

Package Versions

{
    "installed": [
        {
            "name": "nativephp/electron",
            "direct-dependency": true,
            "homepage": "https://github.com/nativephp/electron",
            "source": "https://github.com/NativePHP/electron/tree/0.8.7",
            "version": "0.8.7",
            "description": "Electron wrapper for the NativePHP framework.",
            "abandoned": false
        },
        {
            "name": "nativephp/laravel",
            "direct-dependency": false,
            "homepage": "https://github.com/nativephp/laravel",
            "source": "https://github.com/NativePHP/laravel/tree/0.6.4",
            "version": "0.6.4",
            "description": "Laravel wrapper for the NativePHP framework.",
            "abandoned": false
        },
        {
            "name": "nativephp/php-bin",
            "direct-dependency": false,
            "homepage": "https://nativephp.com",
            "source": "https://github.com/NativePHP/php-bin/tree/0.5.5",
            "version": "0.5.5",
            "description": "PHP binaries used by the NativePHP framework",
            "abandoned": false
        }
    ]
}

PHP Version

8.2.0

Laravel Version

11.34

Node Version

21.6.2

Which operating systems have you seen this occur on?

Windows

OS version

win 11Pro 24H2

Notes

No response

@labomatik labomatik added the bug Something isn't working label Dec 9, 2024
@amr-coding
Copy link

My guess is that you are using Laravel Herd, and if that is the case, Laravel Herd uses Nginx, which has a problem with rendering .css and .js files of the Flux UI. To resolve this, you should add the following code to your Nginx configuration.

location ~ ^/flux/flux(\.min)?\.(js|css)$ {
    expires off;
    try_files $uri $uri/ /index.php?$query_string;
}

@labomatik
Copy link
Author

There is no Herd in nativePhp (correct me if i'm wrong), the php binary is used and chromium is loading the files
i understand that the /flux routing should be redirected to the index.php? file to have flux working...

@simonhamp
Copy link
Member

I haven't tried to build an app with Flux yet, but I can't see why it would be a problem.

Highly unlikely that Herd has anything to do with what @labomatik is seeing.

The failing filemtime() call suggests that it either can't resolve the path or the actual file is not in that location.

Is the Flux package symlinked in some way in your development environment?

@labomatik
Copy link
Author

labomatik commented Dec 10, 2024

Thanks Simon for your answer, i dived into flux and got similar issue also with livewire.
For livewire i just published the assets and i got .css and .js in the public folder but for flux there is nothing like that, it seems to be generated on the fly from the path /flux
and i don't know why but that generation seems to link to the dev folders /Users/cris/project_nativephp/vendor/livewire/flux/src/

@simonhamp
Copy link
Member

It may be to do with some sort of caching. This may have something to do with a recent change. We removed the minify command, which in part removes the cached folders when it copies files over to the build root.

I will investigate. I have some theories.

@simonhamp simonhamp self-assigned this Dec 10, 2024
@amr-coding
Copy link

Alright, I tried Livewire Flux and NativePHP on a fresh install. I was mistaken about the Laravel Herd part, but unfortunately, I couldn’t reproduce your problem, as everything seemed to work well and all the assets loaded correctly.

@XbNz
Copy link
Contributor

XbNz commented Dec 16, 2024

Flux definitely works. I'm not sure if your problem is Windows-speicifc, but I'm working on an app with Flux on Mac and it works well. I haven't run the build on it yet (waiting for Simon to finish up on some obfuscation stuff), but you can try to run it with php artisan native:serve. Provide your own Flux user/pass in the auth.json after cloning.

https://github.com/XbNz/osintea

@labomatik
Copy link
Author

The issue is happening when you build the package using php artisan native:build and you install it on another machine (macos, windows,...)
This will trigger the issue as all files are not anymore located to your local dev env.

I make it working by copy/pasting the js and css from Flux inside the public folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants