tighten / ziggy

Use your Laravel routes in JavaScript.
MIT License
3.87k stars 247 forks source link

Swoole server not load ziggy-js, Ziggy is not defined error appears. #443

Closed medyun closed 3 years ago

medyun commented 3 years ago

Ziggy version

1.3.4

Laravel version

5.7.29

Description

I'm trying to run my project with swoole, but I'm getting an error in ziggy js. It works fine for the first couple of requests, but then it starts giving the following error.

image

Ziggy call and context

I added @routes declaration into blade.php

Ziggy configuration

When i run console.log(Ziggy), error "Uncaught ReferenceError: Ziggy is not defined" appears.

Route definition

The error is not related to the route definitions.
bakerkretzmar commented 3 years ago

Are you using Octane?

bakerkretzmar commented 3 years ago

Ah never mind, just saw you're on Laravel 5.7. You'll need to reset the internal 'generated' state at the beginning of each request. Take a look at #415 to see how we're doing that for Octane—it should be as simple as BladeRouteGenerator::$generated = false; at the very beginning of each new request cycle. Let me know if that works for you!