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

Route livewire/wire-spy.min.js not registered correctly? #29

Open
LucianoVandi opened this issue Nov 14, 2024 · 0 comments
Open

Route livewire/wire-spy.min.js not registered correctly? #29

LucianoVandi opened this issue Nov 14, 2024 · 0 comments

Comments

@LucianoVandi
Copy link

Environment:

  • Laravel version: 11 (upgraded from v10, old directory structure)
  • Livewire version: 3.5.12
  • wire-elements/wire-spy version: 0.0.9
  • PHP version: 8.2

The route for livewire/wire-spy.min.js defined in the SupportAutoInjectedAssets::provide() method, does not seems to register correctly, causing a 404 error when accessed. After investigating, I found that this issue could be related to the timing of when the route is registered within the application's lifecycle.

After adding logging in SupportAutoInjectedAssets::provide(), I noticed that the method is called before the application has fully registered all routes, which prevents the route from being accessible. However, modifying the route registration in provide() to use App::booted resolves the issue:

class SupportAutoInjectedAssets extends ComponentHook
{
    public static function provide()
    {
        App::booted(function(){
            Route::get('livewire/wire-spy.min.js', function () {
                return response(file_get_contents(base_path('vendor/wire-elements/wire-spy/dist/wire-spy.min.js')))
                    ->header(key: 'content-type', values: 'application/javascript');
            });
        });
    ....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant